@Override public void setPoints(List<P> points , boolean trackIndicies ) { if( forest[0] != null ) { for( int i = 0; i < forest.length; i++ ) memory.recycleGraph(forest[i]); } for( int i = 0; i < forest.length; i++ ) forest[i] = constructor.construct(points,trackIndicies); search1.setTrees(forest); searchN.setTrees(forest); }
@Override public void setPoints(List<P> points , boolean trackIndicies ) { if( forest[0] != null ) { for( int i = 0; i < forest.length; i++ ) memory.recycleGraph(forest[i]); } for( int i = 0; i < forest.length; i++ ) forest[i] = constructor.construct(points,trackIndicies); search1.setTrees(forest); searchN.setTrees(forest); }
@Override public void setPoints(List<P> points, boolean trackIndicies) { if( tree != null ) memory.recycleGraph(tree); tree = constructor.construct(points,trackIndicies); search.setTree(tree); searchN.setTree(tree); }
@Override public void setPoints(List<P> points, boolean trackIndicies) { if( tree != null ) memory.recycleGraph(tree); tree = constructor.construct(points,trackIndicies); search.setTree(tree); searchN.setTree(tree); }
/** * Basic tests to see if it can handle different sized input lists. */ @Test public void construct() { KdTreeConstructor<double[]> alg = new KdTreeConstructor<>(new KdTreeMemory(),createSplitter(1,1,false)); // test an empty list List<double[]> points = new ArrayList<>(); KdTree tree = alg.construct(points,false); assertEquals(2, tree.N); assertNull(tree.root); // add a point points.add( new double[]{1,2}); tree = alg.construct(points,false); assertEquals(2, tree.N); assertSame(tree.root.point, points.get(0)); assertTrue(tree.root.isLeaf()); // add another point. These input points are ignored by the dummy splitter points.add( new double[]{1,2,4,5}); tree = alg.construct(points,false); assertEquals(2, tree.N); assertTrue(tree.root.left.isLeaf()); assertTrue(tree.root.right.isLeaf()); }