@Test public void reverseIterationTest() { Random random = new Random(5743); Persistent23Tree.MutableTree<Integer> tree = new Persistent23Tree<Integer>().beginWrite(); int[] p = genPermutation(random); TreeSet<Integer> added = new TreeSet<>(); for (int i = 0; i < ENTRIES_TO_ADD; i++) { int size = tree.size(); Assert.assertEquals(i, size); if ((size & 1023) == 0 || size < 100) { Iterator<Integer> iterator = added.descendingIterator(); for (Iterator<Integer> treeItr = tree.reverseIterator(); treeItr.hasNext(); ) { Assert.assertTrue(iterator.hasNext()); Integer key = treeItr.next(); Assert.assertEquals(iterator.next(), key); } Assert.assertFalse(iterator.hasNext()); iterator = added.descendingIterator(); Iterator<Integer> treeItr = tree.reverseIterator(); for (int j = 0; j < size; j++) { Integer key = treeItr.next(); Assert.assertTrue(iterator.hasNext()); Assert.assertEquals(iterator.next(), key); } Assert.assertFalse(iterator.hasNext()); try { treeItr.next(); Assert.fail(); } catch (NoSuchElementException e) { } Assert.assertFalse(treeItr.hasNext()); } tree.add(p[i]); added.add(p[i]); } }
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();  }