public void TestCallingClearAndSearch() { // Problem is that Clear destroys the root node. KdTree <Vector> tree = new KdTree <Vector>(2, new Accelerators.Subdivision.SubdivisionPolicyConnector(1)); tree.Add(Vector.Create(1.0, 2.0)); tree.Add(Vector.Create(1.0, 3.0)); tree.Add(Vector.Create(1.0, 4.0)); Accelerators.Searches.ExactSearch <Vector> es = new Accelerators.Searches.ExactSearch <Vector>(tree.Root); tree.Clear(); Assert.IsTrue(Numbered.Empty(es.FindExact(Vector.Create(1.0, 3.0)))); Assert.AreEqual(0, tree.Root.Vectors.Count); Assert.IsTrue(tree.Root.InternalBounds.Empty); }
/// <summary> /// Determines whether the kd-tree contains a specific element. /// </summary> public bool Contains(T item) { Searches.ExactSearch <T> es = new Accelerators.Searches.ExactSearch <T>(this.Root); es.CountLimit = 1; return(!Numbered.Empty(es.FindExact(item))); }