@Test public void testRandomDelete() throws Exception { final Random r = new Random(new Date().getTime()); for (int i = 0; i < 100; i++) { final List<BinarySearchTreeNode<Integer>> nodes = new ArrayList<BinarySearchTreeNode<Integer>>(100); final BinarySearchTree<Integer> tree = generateTree(1000, nodes); assertTreeIsCorrect(tree); Collections.shuffle(nodes); nodes.remove(0); for (BinarySearchTreeNode<Integer> node : nodes) { tree.removeNode(node); assertRemovedNodeEmpty(node); assertTreeIsCorrect(tree); } } }
public boolean removeNode(@Nonnull BinarySearchTreeNode<T> node) { return node.removeSelfFromTree(this); }
BinarySearchTree { public boolean removeNode(@Nonnull BinarySearchTreeNode<T> node) { return node.removeSelfFromTree(this); } }
BinarySearchTree { public boolean removeNode(@Nonnull BinarySearchTreeNode<T> node) { return node.removeSelfFromTree(this); } BinarySearchTree(@Nonnull BinarySearchTreeNode<T> root, @Nonnull Comparator<? super T> comparator); }
BinarySearchTree { public boolean removeNode(@Nonnull BinarySearchTreeNode<T> node) { return node.removeSelfFromTree(this); } BinarySearchTree(@Nonnull BinarySearchTreeNode<T> root, @Nonnull Comparator<? super T> comparator); @Nonnull BinarySearchTreeNode<T> addNode(@Nullable T value); @Nonnull BinarySearchTreeNode<T> addNodeTo(@Nonnull BinarySearchTreeNode<T> node, @Nullable T value); boolean removeNode(@Nonnull BinarySearchTreeNode<T> node); @Nullable BinarySearchTreeNode<T> findNode(@Nullable T value); @Nonnull Comparator<? super T> getComparator(); @Override String toString(); }
BinarySearchTree { public boolean removeNode(@Nonnull BinarySearchTreeNode<T> node) { return node.removeSelfFromTree(this); } BinarySearchTree(@Nonnull BinarySearchTreeNode<T> root, @Nonnull Comparator<? super T> comparator); @Nonnull BinarySearchTreeNode<T> addNode(@Nullable T value); @Nonnull BinarySearchTreeNode<T> addNodeTo(@Nonnull BinarySearchTreeNode<T> node, @Nullable T value); boolean removeNode(@Nonnull BinarySearchTreeNode<T> node); @Nullable BinarySearchTreeNode<T> findNode(@Nullable T value); @Nonnull Comparator<? super T> getComparator(); @Override String toString();  }