All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.atdixon.vivean.swipe.HashTreePSet Maven / Gradle / Ivy

package org.pcollections;

import java.util.Collection;




/**
 *
 * A static convenience class for creating efficient persistent sets.
 * 

* This class simply creates MapPSets backed by HashTreePMaps. * * @author harold */ public final class HashTreePSet { // not instantiable (or subclassable): private HashTreePSet() {} private static final MapPSet EMPTY = MapPSet.from(HashTreePMap.empty()); /** * @param * @return an empty set */ @SuppressWarnings("unchecked") public static MapPSet empty() { return (MapPSet)EMPTY; } /** * @param * @param e * @return empty().plus(e) */ public static MapPSet singleton(final E e) { return HashTreePSet.empty().plus(e); } /** * @param * @param list * @return empty().plusAll(map) */ public static MapPSet from(final Collection list) { return HashTreePSet.empty().plusAll(list); } }