@SuppressWarnings({"OverlyLongMethod"}) @Test public void iterationTest() { Random random = new Random(8234890); Persistent23TreeMap<Integer, String> map = new Persistent23TreeMap<>(); Persistent23TreeMap.MutableMap<Integer, String> write = map.beginWrite(); int[] p = genPermutation(random); TreeSet<Integer> added = new TreeSet<>(); for (int i = 0; i < ENTRIES_TO_ADD; i++) { int size = write.size(); Assert.assertEquals(i, size); if ((size & 1023) == 0 || size < 100) { Iterator<Integer> iterator = added.iterator(); for (Persistent23TreeMap.Entry<Integer, String> key : write) { Assert.assertTrue(iterator.hasNext()); Integer next = iterator.next(); Assert.assertEquals(next, key.getKey()); Assert.assertEquals(String.valueOf(next), key.getValue()); } Assert.assertFalse(iterator.hasNext()); iterator = added.iterator(); Iterator<Persistent23TreeMap.Entry<Integer, String>> treeItr = write.iterator(); for (int j = 0; j < size; j++) { Persistent23TreeMap.Entry<Integer, String> key = treeItr.next(); Assert.assertTrue(iterator.hasNext()); Integer next = iterator.next(); Assert.assertEquals(next, key.getKey()); Assert.assertEquals(String.valueOf(next), key.getValue()); } Assert.assertFalse(iterator.hasNext()); try { treeItr.next(); Assert.fail(); } catch (NoSuchElementException e) { } Assert.assertFalse(treeItr.hasNext()); } write.put(p[i], String.valueOf(p[i])); added.add(p[i]); } }
public MutableMap<K, V> beginWrite() { return new MutableMap<>(set); }
Persistent23TreeMap { public MutableMap<K, V> beginWrite() { return new MutableMap<>(set); } }
Persistent23TreeMap { public MutableMap<K, V> beginWrite() { return new MutableMap<>(set); } Persistent23TreeMap();   Persistent23TreeMap(@Nullable final AbstractPersistent23Tree.RootNode<Entry<K, V>> root); }
Persistent23TreeMap { public MutableMap<K, V> beginWrite() { return new MutableMap<>(set); } Persistent23TreeMap();   Persistent23TreeMap(@Nullable final AbstractPersistent23Tree.RootNode<Entry<K, V>> root); ImmutableMap<K, V> beginRead(); Persistent23TreeMap<K, V> getClone(); MutableMap<K, V> beginWrite(); boolean endWrite(MutableMap<K, V> tree); Entry<K, V> createEntry(K key); }
Persistent23TreeMap { public MutableMap<K, V> beginWrite() { return new MutableMap<>(set); } Persistent23TreeMap();   Persistent23TreeMap(@Nullable final AbstractPersistent23Tree.RootNode<Entry<K, V>> root); ImmutableMap<K, V> beginRead(); Persistent23TreeMap<K, V> getClone(); MutableMap<K, V> beginWrite(); boolean endWrite(MutableMap<K, V> tree); Entry<K, V> createEntry(K key);  }