@CheckReturnValue public HeldLockSet plus(GuardedByExpression lock) { return new HeldLockSet(locks.plus(lock)); }
public void testSet() { PSet<String> a = HashTreePSet.empty(), b = HashTreePSet.empty(); assertEqualsAndHash("empty sets not equal",a,b); assertTrue("adding element should change empty set",!a.equals(a.plus("one"))); a = a.plus("one"); assertEqualsAndHash("adding duplicate should not change set",a,a.plus("one")); a = a.plus("two").plus(""); b = b.plus("two").plus("").plus("one").plus("two"); assertEqualsAndHash(a,b); b = b.plus("three"); assertTrue(!a.equals(b)); int n = b.size(); for(@SuppressWarnings("unused") String s : b) n--; assertTrue("iterator() should return size() elements", n==0); assertEqualsAndHash("adding a set to itself should do nothing",b,b.plusAll(b)); assertEqualsAndHash("adding a set to the empty set should be identity", b, MapPSet.from(HashTreePMap.<String,Object>empty(), b)); // bug Mike found: assertEqualsAndHash(HashTreePSet.from(Arrays.asList(2)), HashTreePSet.empty().plus(1).plus(2).minus(1)); }
@Override public OrderedPSet<E> plus(E e) { if (contents.contains(e)) return this; return new OrderedPSet<E>(contents.plus(e), order.plus(e)); }
@Override public OrderedPSet<E> plus(E e) { if (contents.contains(e)) return this; return new OrderedPSet<E>(contents.plus(e), order.plus(e)); }
public void testBehavesLikePSet() { PSet<Integer> s = Empty.set(); POrderedSet<Integer> os = Empty.orderedSet(); Random r = new Random(); for (int i = 0; i < 100000; i++) { int v = r.nextInt(1000); if (r.nextFloat() < 0.8) { s = s.plus(v); os = os.plus(v); } else { s = s.minus(v); os = os.minus(v); } } assertEquals(s, os); } }
@Override public void visit(Variable variable) { variables = variables.plus(variable); }
/** * @param e * @return * @see org.pcollections.MapPSet#plus(java.lang.Object) */ public PSetX<T> plus(T e) { return new PSetXImpl<>(set.plus(e)); }
@Override public PersistentSetX<T> plus(T e) { return from(get().plus(e)); }
public static <T> Keys<T> from(Collection<Keys<T>> keys) { PSet<Key<T, ?>> result = OrderedPSet.empty(); for (Keys<T> innerKeys : keys) { for (Key<T, ?> key : innerKeys) { result = result.plus(key); } } return new KeySet<>(result); }
@CheckReturnValue public HeldLockSet plus(GuardedByExpression lock) { return new HeldLockSet(locks.plus(lock)); }
@Override public OrderedPSet<E> plus(E e) { if (contents.contains(e)) return this; return new OrderedPSet<E>(contents.plus(e), order.plus(e)); }
@Override public OrderedPSet<E> plus(E e) { if (contents.contains(e)) return this; return new OrderedPSet<E>(contents.plus(e), order.plus(e)); }
@Override public PersistentUniqueList<E> plus(E e) { return !mark.contains(e) ? new PersistentUniqueList<>(contents.plus(e), mark.plus(e)) : this; }
@Override public PersistentUniqueList<E> plus(int i, E e) { return !mark.contains(e) ? new PersistentUniqueList<>(contents.plus(i, e), mark.plus(e)) : this; }