public static <E> PSet<E> set() { return HashTreePSet.empty(); }
public static <E> PSet<E> set() { return HashTreePSet.empty(); }
/** * @param <E> * @param e * @return empty().plus(e) */ public static <E> MapPSet<E> singleton(final E e) { return HashTreePSet.<E>empty().plus(e); }
/** * @param <E> * @param e * @return empty().plus(e) */ public static <E> MapPSet<E> singleton(final E e) { return HashTreePSet.<E>empty().plus(e); }
/** * @param <E> * @param list * @return empty().plusAll(map) */ public static <E> MapPSet<E> from(final Collection<? extends E> list) { return HashTreePSet.<E>empty().plusAll(list); } }
/** * @param <E> * @param list * @return empty().plusAll(map) */ public static <E> MapPSet<E> from(final Collection<? extends E> list) { return HashTreePSet.<E>empty().plusAll(list); } }
@Override protected MapPSet<Object> createEmptyCollection() { return HashTreePSet.empty(); } }
public static <E> PSet<E> set() { return HashTreePSet.empty(); }
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)); }
/** * @param <E> * @param e * @return empty().plus(e) */ public static <E> MapPSet<E> singleton(final E e) { return HashTreePSet.<E>empty().plus(e); }
/** * @param <E> * @param list * @return empty().plusAll(map) */ public static <E> MapPSet<E> from(final Collection<? extends E> list) { return HashTreePSet.<E>empty().plusAll(list); } }
/** * @param <E> * @param e * @return empty().plus(e) */ public static <E> MapPSet<E> singleton(final E e) { return HashTreePSet.<E>empty().plus(e); }
/** * @param <E> * @param list * @return empty().plusAll(map) */ public static <E> MapPSet<E> from(final Collection<? extends E> list) { return HashTreePSet.<E>empty().plusAll(list); } }
public static <T> PSetX<T> empty(){ return new PSetXImpl<>(HashTreePSet .empty()); } public static <T> PSetX<T> singleton(T value){
public static <T> PSet<T> empty(){ return new PSetXImpl<>(HashTreePSet .empty()); } public static <T> PSet<T> singleton(T value){
void release(Class type,List<Proxy> proxies){ mergeProxies(type,proxies.stream().map(ProxyWrapper::new) .map(HashTreePSet::singleton) .reduce(HashTreePSet.empty(),(acc,next) -> acc.plusAll(next))); }
public void testSerializationForMapPSet() { final MapPSet<String> initialMapPSet = HashTreePSet.<String> empty() .plus(ELEMENT1) .plus(ELEMENT2) .plus(ELEMENT3); final byte[] serializedMapPSet = serializeToByteArray(initialMapPSet); assertNotNull(serializedMapPSet); assertTrue(serializedMapPSet.length > 0); @SuppressWarnings("unchecked") final MapPSet<String> deserializedMapPSet = deserializeFromByteArray(serializedMapPSet, MapPSet.class); assertNotNull(deserializedMapPSet); assertEquals(3, deserializedMapPSet.size()); assertNotSame(initialMapPSet, deserializedMapPSet); assertTrue(deserializedMapPSet.containsAll(Arrays.asList(ELEMENT1, ELEMENT2, ELEMENT3))); assertTrue(deserializedMapPSet.minus(ELEMENT1).minus(ELEMENT2).minus(ELEMENT3).isEmpty()); }
public static <T> PersistentSetX<T> empty() { return new LazyPSetX<>( HashTreePSet.empty(),null,Reducers.toPSet(), LAZY); }
public static <T> Monoid<PSet<T>> toPSet() { return Monoid.<PSet<T>>of(HashTreePSet.empty(), (PSet<T> a) -> b -> a.plusAll(b), (T x) -> HashTreePSet.singleton(x)); } public static <T> Monoid<PVector<T>> toPVector() {
/** * <pre> * {@code * PSet<Integer> q = Reducers.<Integer>toPSet() .mapReduce(Stream.of(1,2,3,4)); * * } * </pre> * @return Reducer for PSet */ public static <T> Reducer<PSet<T>> toPSet() { return Reducer.<PSet<T>> of(HashTreePSet.empty(), (final PSet<T> a) -> b -> a.plusAll(b), (final T x) -> HashTreePSet.singleton(x)); } /**