public MapPSet<E> plusAll(final Collection<? extends E> list) { PMap<E,Object> map = this.map; for(E e : list) map = map.plus(e, In.IN); return from(map); }
/** * @param <E> * @param map * @param list * @return from(map).plusAll(list) */ public static <E> MapPSet<E> from(final PMap<E,?> map, final Collection<? extends E> list) { return from(map).plusAll(list); }
public MapPSet<E> minusAll(final Collection<?> list) { PMap<E,Object> map = this.map.minusAll(list); return from(map); } }
/** * @param <E> * @param map * @param list * @return from(map).plusAll(list) */ public static <E> MapPSet<E> from(final PMap<E,?> map, final Collection<? extends E> list) { return from(map).plusAll(list); }
public MapPSet<E> minusAll(final Collection<?> list) { PMap<E,Object> map = this.map.minusAll(list); return from(map); } }
/** * @param <E> * @param map * @param e * @return from(map).plus(e) */ public static <E> MapPSet<E> from(final PMap<E,?> map, E e) { return from(map).plus(e); }
/** * @param <E> * @param map * @param e * @return from(map).plus(e) */ public static <E> MapPSet<E> from(final PMap<E,?> map, E e) { return from(map).plus(e); }
public MapPSet<E> plusAll(final Collection<? extends E> list) { PMap<E,Object> map = this.map; for(E e : list) map = map.plus(e, In.IN); return from(map); }
public MapPSet<E> plusAll(final Collection<? extends E> list) { PMap<E,Object> map = this.map; for(E e : list) map = map.plus(e, In.IN); return from(map); }
/** * @param <E> * @param map * @param list * @return from(map).plusAll(list) */ public static <E> MapPSet<E> from(final PMap<E,?> map, final Collection<? extends E> list) { return from(map).plusAll(list); }
/** * @param <E> * @param map * @param e * @return from(map).plus(e) */ public static <E> MapPSet<E> from(final PMap<E, ?> map, E e) { return from(map).plus(e); }
/** * @param <E> * @param map * @param e * @return from(map).plus(e) */ public static <E> MapPSet<E> from(final PMap<E,?> map, E e) { return from(map).plus(e); }
/** * @param <E> * @param map * @param list * @return from(map).plusAll(list) */ public static <E> MapPSet<E> from(final PMap<E, ?> map, final Collection<? extends E> list) { return from(map).plusAll(list); }
public MapPSet<E> minusAll(final Collection<?> list) { PMap<E,Object> map = this.map.minusAll(list); return from(map); } }
public MapPSet<E> plusAll(final Collection<? extends E> list) { PMap<E, Object> map = this.map; for (E e : list) map = map.plus(e, In.IN); return from(map); }
public MapPSet<E> minusAll(final Collection<?> list) { PMap<E, Object> map = this.map.minusAll(list); return from(map); }
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)); }