SplayTree { public void delete(int elem) { splay(elem); if (root.key != elem) return; SplayNode removed = root; if (root.left == null) { root = root.right; if (root != null) root.parent = null; } else { SplayNode right = root.right; root = root.left; root.parent = null; splay(elem); root.right = right; if (root.right != null) root.right.parent = root; } }  void add(int key, Object elem); boolean find(int key); void delete(int elem);  }
@Test public void testDelete() throws Exception { rand.nextInt(inserted.length); List<Integer> ints = Arrays.asList(inserted); Collections.shuffle(ints); for (Integer i : ints) { tree.delete(i); } }