@NotThreadSafe public class UnifiedSet<T> extends AbstractUnifiedSet<T> implements Externalizable
| Constructor and Description | 
|---|
| UnifiedSet() | 
| UnifiedSet(Collection<? extends T> collection) | 
| UnifiedSet(int initialCapacity) | 
| UnifiedSet(int initialCapacity,
          float loadFactor) | 
| UnifiedSet(UnifiedSet<T> set) | 
| Modifier and Type | Method and Description | 
|---|---|
| boolean | add(T key) | 
| boolean | addAllIterable(Iterable<? extends T> iterable) | 
| ParallelUnsortedSetIterable<T> | asParallel(ExecutorService executorService,
          int batchSize)Returns a parallel iterable of this SetIterable. | 
| void | batchForEach(Procedure<? super T> procedure,
            int sectionIndex,
            int sectionCount) | 
| void | clear() | 
| UnifiedSet<T> | clone() | 
| boolean | contains(Object key)Returns true if the iterable has an element which responds true to element.equals(object). | 
| void | each(Procedure<? super T> procedure)The procedure is executed for each element in the iterable. | 
| boolean | equals(Object object)Follows the same general contract as  Set.equals(Object). | 
| <P> void | forEachWith(Procedure2<? super T,? super P> procedure,
           P parameter)The procedure2 is evaluated for each element in the iterable with the specified parameter provided
 as the second argument. | 
| void | forEachWithIndex(ObjectIntProcedure<? super T> objectIntProcedure)Iterates over the iterable passing each element and the current relative int index to the specified instance of
 ObjectIntProcedure. | 
| T | get(T key)Locates an object in the pool which is equal to  key. | 
| T | getFirst()Returns the first element of an iterable. | 
| T | getLast()Returns the last element of an iterable. | 
| <V> UnifiedSetMultimap<V,T> | groupBy(Function<? super T,? extends V> function)For each element of the iterable, the function is evaluated and the results of these evaluations are collected
 into a new multimap, where the transformed value is the key and the original values are added to the same (or similar)
 species of collection as the source iterable. | 
| <V> UnifiedSetMultimap<V,T> | groupByEach(Function<? super T,? extends Iterable<V>> function)Similar to  RichIterable.groupBy(Function), except the result of evaluating function will return a collection of keys
 for each value. | 
| int | hashCode()Follows the same general contract as  Set.hashCode(). | 
| Iterator<T> | iterator() | 
| UnifiedSet<T> | newEmpty()Creates a new empty mutable version of the same collection type. | 
| static <K> UnifiedSet<K> | newSet() | 
| static <K> UnifiedSet<K> | newSet(int size) | 
| static <K> UnifiedSet<K> | newSet(int size,
      float loadFactor) | 
| static <K> UnifiedSet<K> | newSet(Iterable<? extends K> source) | 
| static <K> UnifiedSet<K> | newSetWith(K... elements) | 
| PartitionMutableSet<T> | partition(Predicate<? super T> predicate)Filters a collection into a PartitionedIterable based on the evaluation of the predicate. | 
| <P> PartitionMutableSet<T> | partitionWith(Predicate2<? super T,? super P> predicate,
             P parameter)Filters a collection into a PartitionIterable based on the evaluation of the predicate. | 
| T | put(T key)Puts  keyinto the pool. | 
| void | readExternal(ObjectInput in) | 
| UnifiedSet<T> | reject(Predicate<? super T> predicate)Returns all elements of the source collection that return false when evaluating of the predicate. | 
| <P> UnifiedSet<T> | rejectWith(Predicate2<? super T,? super P> predicate,
          P parameter)Similar to  RichIterable.reject(Predicate), except with an evaluation parameter for the second generic argument inPredicate2. | 
| boolean | remove(Object key) | 
| T | removeFromPool(T key)Locates an object in the pool which is equal to  keyand removes it. | 
| boolean | retainAllIterable(Iterable<?> iterable) | 
| UnifiedSet<T> | select(Predicate<? super T> predicate)Returns all elements of the source collection that return true when evaluating the predicate. | 
| <P> Twin<MutableList<T>> | selectAndRejectWith(Predicate2<? super T,? super P> predicate,
                   P parameter)Filters a collection into two separate collections based on a predicate returned via a Pair. | 
| <S> UnifiedSet<S> | selectInstancesOf(Class<S> clazz)Returns all elements of the source collection that are instances of the Class  clazz. | 
| <P> UnifiedSet<T> | selectWith(Predicate2<? super T,? super P> predicate,
          P parameter)Similar to  RichIterable.select(Predicate), except with an evaluation parameter for the second generic argument inPredicate2. | 
| int | size()Returns the number of items in this iterable. | 
| MutableSet<T> | tap(Procedure<? super T> procedure)Executes the Procedure for each element in the iterable and returns  this. | 
| Object[] | toArray()Converts this iterable to an array. | 
| <T> T[] | toArray(T[] array)Converts this iterable to an array using the specified target array, assuming the target array is as long
 or longer than the iterable. | 
| ImmutableSet<T> | toImmutable()Returns an immutable copy of this set. | 
| UnifiedSet<T> | with(T... elements) | 
| UnifiedSet<T> | with(T element)This method allows mutable and fixed size collections the ability to add elements to their existing elements. | 
| UnifiedSet<T> | with(T element1,
    T element2) | 
| UnifiedSet<T> | with(T element1,
    T element2,
    T element3) | 
| UnifiedSet<T> | withAll(Iterable<? extends T> iterable)This method allows mutable and fixed size collections the ability to add multiple elements to their existing
 elements. | 
| UnifiedSet<T> | without(T element)This method allows mutable and fixed size collections the ability to remove elements from their existing elements. | 
| UnifiedSet<T> | withoutAll(Iterable<? extends T> elements)This method allows mutable and fixed size collections the ability to remove multiple elements from their existing
 elements. | 
| void | writeExternal(ObjectOutput out) | 
allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, asSynchronized, asUnmodifiable, cartesianProduct, chunk, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, detect, detectOptional, difference, differenceInto, flatCollect, getBatchCount, groupByUniqueKey, injectIntoWith, intersect, intersectInto, isProperSubsetOf, isSubsetOf, noneSatisfy, noneSatisfyWith, powerSet, removeAllIterable, retainAll, symmetricDifference, symmetricDifferenceInto, union, unionInto, zip, zipWithIndexaddAll, aggregateBy, aggregateInPlaceBy, reduce, removeAll, removeIf, removeIfWith, sumByDouble, sumByFloat, sumByInt, sumByLongappendString, appendString, asLazy, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, containsAll, containsAllArguments, containsAllIterable, count, countWith, detectIfNone, detectWith, detectWithIfNone, detectWithOptional, flatCollect, forEach, groupBy, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, into, isEmpty, max, max, maxBy, min, min, minBy, reject, rejectWith, select, selectWith, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toBag, toList, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedSet, toSortedSet, toSortedSetBy, toString, zip, zipWithIndexaggregateBy, aggregateInPlaceBy, removeIf, removeIfWith, sumByDouble, sumByFloat, sumByInt, sumByLongappendString, appendString, appendString, asLazy, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, containsAll, containsAllArguments, containsAllIterable, count, countWith, detectIfNone, detectWith, detectWithIfNone, detectWithOptional, flatCollect, getOnly, groupBy, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, into, isEmpty, makeString, makeString, makeString, max, max, maxBy, min, min, minBy, notEmpty, reduce, reduceInPlace, reduceInPlace, reject, rejectWith, select, selectWith, summarizeDouble, summarizeFloat, summarizeInt, summarizeLong, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toBag, toList, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedSet, toSortedSet, toSortedSetBy, toString, zip, zipWithIndexforEachaddAll, containsAll, isEmpty, removeAll, spliteratorparallelStream, removeIf, streamforEachpublic UnifiedSet()
public UnifiedSet(int initialCapacity)
public UnifiedSet(int initialCapacity,
                  float loadFactor)
public UnifiedSet(Collection<? extends T> collection)
public UnifiedSet(UnifiedSet<T> set)
public static <K> UnifiedSet<K> newSet()
public static <K> UnifiedSet<K> newSet(int size)
public static <K> UnifiedSet<K> newSet(Iterable<? extends K> source)
public static <K> UnifiedSet<K> newSet(int size, float loadFactor)
public static <K> UnifiedSet<K> newSetWith(K... elements)
public void clear()
public boolean add(T key)
add in interface Collection<T>add in interface Set<T>add in class AbstractMutableCollection<T>public boolean contains(Object key)
RichIterablecontains in interface Collection<T>contains in interface Set<T>contains in interface RichIterable<T>contains in class AbstractRichIterable<T>public void batchForEach(Procedure<? super T> procedure, int sectionIndex, int sectionCount)
batchForEach in interface BatchIterable<T>public MutableSet<T> tap(Procedure<? super T> procedure)
RichIterablethis.
 Example using a Java 8 lambda expression:
 RichIterable<Person> tapped =
     people.tap(person -> LOGGER.info(person.getName()));
 
 Example using an anonymous inner class:
 RichIterable<Person> tapped =
     people.tap(new Procedure()
     {
         public void value(Person person)
         {
             LOGGER.info(person.getName());
         }
     });
  tap in interface MutableCollection<T>tap in interface RichIterable<T>tap in interface MutableSet<T>tap in interface MutableSetIterable<T>tap in interface SetIterable<T>tap in interface UnsortedSetIterable<T>RichIterable.each(Procedure), 
InternalIterable.forEach(Procedure)public void each(Procedure<? super T> procedure)
RichIterableExample using a Java 8 lambda expression:
people.each(person -> LOGGER.info(person.getName()));
Example using an anonymous inner class:
people.each(new ProcedureThis method is a variant of() { public void value(Person person) { LOGGER.info(person.getName()); } }); 
InternalIterable.forEach(Procedure)
 that has a signature conflict with Iterable.forEach(java.util.function.Consumer).each in interface RichIterable<T>InternalIterable.forEach(Procedure), 
Iterable.forEach(java.util.function.Consumer)public <P> void forEachWith(Procedure2<? super T,? super P> procedure, P parameter)
InternalIterableExample using a Java 8 lambda:
 people.forEachWith((Person person, Person other) ->
     {
         if (person.isRelatedTo(other))
         {
              LOGGER.info(person.getName());
         }
     }, fred);
 
 Example using an anonymous inner class:
people.forEachWith(new Procedure2() { public void value(Person person, Person other) { if (person.isRelatedTo(other)) { LOGGER.info(person.getName()); } } }, fred); 
forEachWith in interface InternalIterable<T>forEachWith in class AbstractRichIterable<T>public void forEachWithIndex(ObjectIntProcedure<? super T> objectIntProcedure)
InternalIterableExample using a Java 8 lambda:
 people.forEachWithIndex((Person person, int index) -> LOGGER.info("Index: " + index + " person: " + person.getName()));
 
 Example using an anonymous inner class:
people.forEachWithIndex(new ObjectIntProcedure() { public void value(Person person, int index) { LOGGER.info("Index: " + index + " person: " + person.getName()); } }); 
forEachWithIndex in interface InternalIterable<T>forEachWithIndex in class AbstractRichIterable<T>public UnifiedSet<T> newEmpty()
MutableCollectionnewEmpty in interface MutableCollection<T>newEmpty in interface MutableSet<T>public T getFirst()
RichIterableThe order of Sets are not guaranteed (except for TreeSets and other Ordered Set implementations), so if you use this method, the first element could be any element from the Set.
getFirst in interface RichIterable<T>public T getLast()
RichIterableThe order of Sets are not guaranteed (except for TreeSets and other Ordered Set implementations), so if you use this method, the last element could be any element from the Set.
getLast in interface RichIterable<T>public UnifiedSet<T> select(Predicate<? super T> predicate)
RichIterableExample using a Java 8 lambda expression:
 RichIterable<Person> selected =
     people.select(person -> person.getAddress().getCity().equals("London"));
 
 Example using an anonymous inner class:
 RichIterable<Person> selected =
     people.select(new Predicate<Person>()
     {
         public boolean accept(Person person)
         {
             return person.getAddress().getCity().equals("London");
         }
     });select in interface MutableCollection<T>select in interface RichIterable<T>select in interface MutableSet<T>select in interface MutableSetIterable<T>select in interface SetIterable<T>select in interface UnsortedSetIterable<T>public <P> UnifiedSet<T> selectWith(Predicate2<? super T,? super P> predicate, P parameter)
RichIterableRichIterable.select(Predicate), except with an evaluation parameter for the second generic argument in Predicate2.
 
 E.g. return a Collection of Person elements where the person has an age greater than or equal to 18 years
 
Example using a Java 8 lambda expression:
 RichIterable<Person> selected =
     people.selectWith((Person person, Integer age) -> person.getAge() >= age, Integer.valueOf(18));
 
 Example using an anonymous inner class:
 RichIterable<Person> selected =
     people.selectWith(new Predicate2<Person, Integer>()
     {
         public boolean accept(Person person, Integer age)
         {
             return person.getAge() >= age;
         }
     }, Integer.valueOf(18));
 selectWith in interface MutableCollection<T>selectWith in interface RichIterable<T>selectWith in interface MutableSet<T>selectWith in interface MutableSetIterable<T>selectWith in interface SetIterable<T>selectWith in interface UnsortedSetIterable<T>predicate - a Predicate2 to use as the select criteriaparameter - a parameter to pass in for evaluation of the second argument P in predicateRichIterable.select(Predicate)public UnifiedSet<T> reject(Predicate<? super T> predicate)
RichIterableExample using a Java 8 lambda expression:
 RichIterable<Person> rejected =
     people.reject(person -> person.person.getLastName().equals("Smith"));
 
 Example using an anonymous inner class:
 RichIterable<Person> rejected =
     people.reject(new Predicate<Person>()
     {
         public boolean accept(Person person)
         {
             return person.person.getLastName().equals("Smith");
         }
     });
 reject in interface MutableCollection<T>reject in interface RichIterable<T>reject in interface MutableSet<T>reject in interface MutableSetIterable<T>reject in interface SetIterable<T>reject in interface UnsortedSetIterable<T>predicate - a Predicate to use as the reject criteriaPredicate.accept(Object) method to evaluate to falsepublic <P> UnifiedSet<T> rejectWith(Predicate2<? super T,? super P> predicate, P parameter)
RichIterableRichIterable.reject(Predicate), except with an evaluation parameter for the second generic argument in Predicate2.
 
 E.g. return a Collection of Person elements where the person has an age greater than or equal to 18 years
 
Example using a Java 8 lambda expression:
 RichIterable<Person> rejected =
     people.rejectWith((Person person, Integer age) -> person.getAge() < age, Integer.valueOf(18));
 
 Example using an anonymous inner class:
 MutableList<Person> rejected =
     people.rejectWith(new Predicate2<Person, Integer>()
     {
         public boolean accept(Person person, Integer age)
         {
             return person.getAge() < age;
         }
     }, Integer.valueOf(18));
 rejectWith in interface MutableCollection<T>rejectWith in interface RichIterable<T>rejectWith in interface MutableSet<T>rejectWith in interface MutableSetIterable<T>rejectWith in interface SetIterable<T>rejectWith in interface UnsortedSetIterable<T>predicate - a Predicate2 to use as the select criteriaparameter - a parameter to pass in for evaluation of the second argument P in predicateRichIterable.select(Predicate)public <P> Twin<MutableList<T>> selectAndRejectWith(Predicate2<? super T,? super P> predicate, P parameter)
MutableCollection
e.g. return lastNames.selectAndRejectWith(PredicatesLite.lessThan(), "Mason");
selectAndRejectWith in interface MutableCollection<T>selectAndRejectWith in class AbstractMutableCollection<T>public PartitionMutableSet<T> partition(Predicate<? super T> predicate)
RichIterableExample using a Java 8 lambda expression:
 PartitionIterable<Person> newYorkersAndNonNewYorkers =
     people.partition(person -> person.getAddress().getState().getName().equals("New York"));
 
 Example using an anonymous inner class:
 PartitionIterable<Person> newYorkersAndNonNewYorkers =
     people.partition(new Predicate<Person>()
     {
         public boolean accept(Person person)
         {
             return person.getAddress().getState().getName().equals("New York");
         }
     });
 partition in interface MutableCollection<T>partition in interface RichIterable<T>partition in interface MutableSet<T>partition in interface MutableSetIterable<T>partition in interface SetIterable<T>public <P> PartitionMutableSet<T> partitionWith(Predicate2<? super T,? super P> predicate, P parameter)
RichIterableExample using a Java 8 lambda expression:
 PartitionIterable<Person>> newYorkersAndNonNewYorkers =
     people.partitionWith((Person person, String state) -> person.getAddress().getState().getName().equals(state), "New York");
 
 Example using an anonymous inner class:
 PartitionIterable<Person>> newYorkersAndNonNewYorkers =
     people.partitionWith(new Predicate2<Person, String>()
     {
         public boolean accept(Person person, String state)
         {
             return person.getAddress().getState().getName().equals(state);
         }
     }, "New York");
 partitionWith in interface MutableCollection<T>partitionWith in interface RichIterable<T>partitionWith in interface MutableSet<T>partitionWith in interface MutableSetIterable<T>partitionWith in interface SetIterable<T>public <S> UnifiedSet<S> selectInstancesOf(Class<S> clazz)
RichIterableclazz.selectInstancesOf in interface MutableCollection<T>selectInstancesOf in interface RichIterable<T>selectInstancesOf in interface MutableSet<T>selectInstancesOf in interface MutableSetIterable<T>selectInstancesOf in interface SetIterable<T>selectInstancesOf in interface UnsortedSetIterable<T>public ImmutableSet<T> toImmutable()
MutableSetThe returned set will be Serializable if this set is Serializable.
toImmutable in interface MutableCollection<T>toImmutable in interface MutableSet<T>toImmutable in interface SetIterable<T>toImmutable in interface UnsortedSetIterable<T>public UnifiedSet<T> with(T element)
MutableCollection
MutableCollectionIn the case oflist; list = list.with("1"); list = list.with("2"); return list; 
FixedSizeCollection a new instance of MutableCollection will be returned by with, and any
 variables that previously referenced the original collection will need to be redirected to reference the
 new instance.  For other MutableCollection types you will replace the reference to collection with the same
 collection, since the instance will return "this" after calling add on itself.with in interface MutableCollection<T>with in interface MutableSet<T>Collection.add(Object)public UnifiedSet<T> with(T element1, T element2)
public UnifiedSet<T> with(T element1, T element2, T element3)
public UnifiedSet<T> with(T... elements)
public UnifiedSet<T> withAll(Iterable<? extends T> iterable)
MutableCollection
MutableCollectionIn the case oflist; list = list.withAll(FastList.newListWith("1", "2")); return list; 
FixedSizeCollection a new instance of MutableCollection will be returned by withAll, and
 any variables that previously referenced the original collection will need to be redirected to reference the
 new instance.  For other MutableCollection types you will replace the reference to collection with the same
 collection, since the instance will return "this" after calling addAll on itself.withAll in interface MutableCollection<T>withAll in interface MutableSet<T>Collection.addAll(Collection)public UnifiedSet<T> without(T element)
MutableCollection
MutableCollectionIn the case oflist; list = list.without("1"); list = list.without("2"); return list; 
FixedSizeCollection a new instance of MutableCollection will be returned by without, and
 any variables that previously referenced the original collection will need to be redirected to reference the
 new instance.  For other MutableCollection types you will replace the reference to collection with the same
 collection, since the instance will return "this" after calling remove on itself.without in interface MutableCollection<T>without in interface MutableSet<T>Collection.remove(Object)public UnifiedSet<T> withoutAll(Iterable<? extends T> elements)
MutableCollection
MutableCollectionIn the case oflist; list = list.withoutAll(FastList.newListWith("1", "2")); return list; 
FixedSizeCollection a new instance of MutableCollection will be returned by withoutAll,
 and any variables that previously referenced the original collection will need to be redirected to reference the
 new instance.  For other MutableCollection types you will replace the reference to collection with the same
 collection, since the instance will return "this" after calling removeAll on itself.withoutAll in interface MutableCollection<T>withoutAll in interface MutableSet<T>Collection.removeAll(Collection)public boolean addAllIterable(Iterable<? extends T> iterable)
addAllIterable in interface MutableCollection<T>addAllIterable in class AbstractMutableCollection<T>Collection.addAll(Collection)public boolean remove(Object key)
remove in interface Collection<T>remove in interface Set<T>remove in class AbstractMutableCollection<T>public int size()
RichIterablesize in interface Collection<T>size in interface Set<T>size in interface RichIterable<T>size in interface Pool<T>size in interface BatchIterable<T>public boolean equals(Object object)
SetIterableSet.equals(Object).public int hashCode()
SetIterableSet.hashCode().public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal in interface ExternalizableIOExceptionClassNotFoundExceptionpublic void writeExternal(ObjectOutput out) throws IOException
writeExternal in interface ExternalizableIOExceptionpublic boolean retainAllIterable(Iterable<?> iterable)
retainAllIterable in interface MutableCollection<T>retainAllIterable in class AbstractMutableCollection<T>Collection.retainAll(Collection)public UnifiedSet<T> clone()
clone in interface MutableSet<T>clone in class AbstractUnifiedSet<T>public Object[] toArray()
RichIterabletoArray in interface Collection<T>toArray in interface Set<T>toArray in interface RichIterable<T>toArray in class AbstractRichIterable<T>Collection.toArray()public <T> T[] toArray(T[] array)
RichIterabletoArray in interface Collection<T>toArray in interface Set<T>toArray in interface RichIterable<T>toArray in class AbstractRichIterable<T>Collection.toArray(Object[])public <V> UnifiedSetMultimap<V,T> groupBy(Function<? super T,? extends V> function)
RichIterableExample using a Java 8 method reference:
 Multimap<String, Person> peopleByLastName =
     people.groupBy(Person::getLastName);
 
 Example using an anonymous inner class:
 Multimap<String, Person> peopleByLastName =
     people.groupBy(new Function<Person, String>()
     {
         public String valueOf(Person person)
         {
             return person.getLastName();
         }
     });
 groupBy in interface MutableCollection<T>groupBy in interface RichIterable<T>groupBy in interface MutableSet<T>groupBy in interface MutableSetIterable<T>groupBy in interface UnsortedSetIterable<T>public <V> UnifiedSetMultimap<V,T> groupByEach(Function<? super T,? extends Iterable<V>> function)
RichIterableRichIterable.groupBy(Function), except the result of evaluating function will return a collection of keys
 for each value.groupByEach in interface MutableCollection<T>groupByEach in interface RichIterable<T>groupByEach in interface MutableSet<T>groupByEach in interface MutableSetIterable<T>groupByEach in interface UnsortedSetIterable<T>public T get(T key)
Poolkey.public T put(T key)
Poolkey into the pool. If there is no existing object that is equal
 to key, key will be added to the pool and the return value will be the same instance.
 If there is an existing object in the pool that is equal to key, the pool will remain unchanged
 and the pooled instance will be is returned.public T removeFromPool(T key)
Poolkey and removes it.removeFromPool in interface Pool<T>key - object to removepublic ParallelUnsortedSetIterable<T> asParallel(ExecutorService executorService, int batchSize)
SetIterableasParallel in interface SetIterable<T>asParallel in interface UnsortedSetIterable<T>Copyright © 2004–2016. All rights reserved.