@Test public void iterationBenchmark() { final Persistent23Tree.MutableTree<Integer> tree = new Persistent23Tree<Integer>().beginWrite(); final int count = 100000; for (int i = 0; i < count; ++i) { tree.add(i); } TestUtil.time("Persistent23Tree iteration", () -> { for (int i = 0; i < 300; ++i) { int prev = Integer.MIN_VALUE; Assert.assertFalse(tree.contains(prev)); final Iterator<Integer> it = tree.iterator(); int j = 0; while (it.hasNext()) { j = it.next(); Assert.assertTrue(prev < j); prev = j; } Assert.assertEquals(count - 1, j); } }); TestUtil.time("Persistent23Tree reverse iteration", () -> { for (int i = 0; i < 300; ++i) { int prev = Integer.MAX_VALUE; Assert.assertFalse(tree.contains(prev)); final Iterator<Integer> it = tree.reverseIterator(); int j = 0; while (it.hasNext()) { j = it.next(); Assert.assertTrue(prev > j); prev = j; } Assert.assertEquals(0, j); } }); }
public MutableTree<K> beginWrite() { return new MutableTree<>(this); }
Persistent23Tree extends AbstractPersistent23Tree<K> { public MutableTree<K> beginWrite() { return new MutableTree<>(this); } }
Persistent23Tree extends AbstractPersistent23Tree<K> { public MutableTree<K> beginWrite() { return new MutableTree<>(this); } Persistent23Tree();   Persistent23Tree(@Nullable final AbstractPersistent23Tree.RootNode<K> root); }
Persistent23Tree extends AbstractPersistent23Tree<K> { public MutableTree<K> beginWrite() { return new MutableTree<>(this); } Persistent23Tree();   Persistent23Tree(@Nullable final AbstractPersistent23Tree.RootNode<K> root); ImmutableTree<K> beginRead(); Persistent23Tree<K> getClone(); MutableTree<K> beginWrite(); }
Persistent23Tree extends AbstractPersistent23Tree<K> { public MutableTree<K> beginWrite() { return new MutableTree<>(this); } Persistent23Tree();   Persistent23Tree(@Nullable final AbstractPersistent23Tree.RootNode<K> root); ImmutableTree<K> beginRead(); Persistent23Tree<K> getClone(); MutableTree<K> beginWrite();  }