@Test public void iterationTest() { Random random = new Random(8234890); PersistentHashSet.MutablePersistentHashSet<Integer> tree = new PersistentHashSet<Integer>().beginWrite(); int[] p = genPermutation(random); HashSet<Integer> added = new HashSet<>(); for (int i = 0; i < ENTRIES_TO_ADD; i++) { int size = tree.size(); Assert.assertEquals(i, size); if ((size & 1023) == 0 || size < 100) { Collection<Integer> actual = new HashSet<>(size); for (Integer key : tree) { Assert.assertFalse(actual.contains(key)); actual.add(key); } Assert.assertEquals(size, actual.size()); for (Integer key : added) { Assert.assertTrue(actual.contains(key)); } Iterator<Integer> treeItr = tree.iterator(); actual.clear(); for (int j = 0; j < size; j++) { Integer key = treeItr.next(); Assert.assertFalse(actual.contains(key)); actual.add(key); } Assert.assertEquals(size, actual.size()); for (Integer key : added) { Assert.assertTrue(actual.contains(key)); } } tree.add(p[i]); added.add(p[i]); } }
public MutablePersistentHashSet<K> beginWrite() { return new MutablePersistentHashSet<>(this); }
PersistentHashSet extends AbstractPersistentHashSet<K> { public MutablePersistentHashSet<K> beginWrite() { return new MutablePersistentHashSet<>(this); } }
PersistentHashSet extends AbstractPersistentHashSet<K> { public MutablePersistentHashSet<K> beginWrite() { return new MutablePersistentHashSet<>(this); } @SuppressWarnings("unchecked")  PersistentHashSet();  PersistentHashSet(@NotNull final AbstractPersistentHashSet.RootTableNode<K> root); }
PersistentHashSet extends AbstractPersistentHashSet<K> { public MutablePersistentHashSet<K> beginWrite() { return new MutablePersistentHashSet<>(this); } @SuppressWarnings("unchecked")  PersistentHashSet();  PersistentHashSet(@NotNull final AbstractPersistentHashSet.RootTableNode<K> root); ImmutablePersistentHashSet<K> beginRead(); PersistentHashSet<K> getClone(); MutablePersistentHashSet<K> beginWrite(); }
PersistentHashSet extends AbstractPersistentHashSet<K> { public MutablePersistentHashSet<K> beginWrite() { return new MutablePersistentHashSet<>(this); } @SuppressWarnings("unchecked")  PersistentHashSet();  PersistentHashSet(@NotNull final AbstractPersistentHashSet.RootTableNode<K> root); ImmutablePersistentHashSet<K> beginRead(); PersistentHashSet<K> getClone(); MutablePersistentHashSet<K> beginWrite();  }