Class UnifiedSet<T>
- All Implemented Interfaces:
Externalizable, Serializable, Cloneable, Iterable<T>, Collection<T>, Set<T>, MutableCollection<T>, InternalIterable<T>, RichIterable<T>, MutableSet<T>, MutableSetIterable<T>, Pool<T>, SetIterable<T>, UnsortedSetIterable<T>, BatchIterable<T>
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final classprotected classprivate final classprivate final class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Objectprotected intprivate static final longprotected Object[]Fields inherited from class AbstractUnifiedSet
DEFAULT_INITIAL_CAPACITY, DEFAULT_LOAD_FACTOR, loadFactor, maxSize -
Constructor Summary
ConstructorsConstructorDescriptionUnifiedSet(int initialCapacity) UnifiedSet(int initialCapacity, float loadFactor) UnifiedSet(Collection<? extends T> collection) UnifiedSet(UnifiedSet<T> set) -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanaddAllIterable(Iterable<? extends T> iterable) private voidaddForTrim(Object key, int oldIndex, int mask) private voidaddIfFound(T key, UnifiedSet<T> other) private voidaddIfFoundFromChain(UnifiedSet.ChainedBucket bucket, T key, UnifiedSet<T> other) protected voidallocateTable(int sizeToAllocate) asParallel(ExecutorService executorService, int batchSize) Returns a parallel iterable of this SetIterable.voidbatchForEach(Procedure<? super T> procedure, int sectionIndex, int sectionCount) private booleanchainContains(UnifiedSet.ChainedBucket bucket, T key) private booleanchainedAdd(T key, int index) private voidchainedAddForTrim(Object key, int index) private ObjectchainedDetect(UnifiedSet.ChainedBucket bucket, Predicate<? super T> predicate) private voidchainedForEach(UnifiedSet.ChainedBucket bucket, Procedure<? super T> procedure) private <P> voidchainedForEachWith(UnifiedSet.ChainedBucket bucket, Procedure2<? super T, ? super P> procedure, P parameter) private intchainedForEachWithIndex(UnifiedSet.ChainedBucket bucket, ObjectIntProcedure<? super T> procedure, int count) private TchainedGet(T key, UnifiedSet.ChainedBucket bucket) private intprivate TchainedPut(T key, int index) private booleanchainedShortCircuit(UnifiedSet.ChainedBucket bucket, Predicate<? super T> predicate, boolean expected) private <P> booleanchainedShortCircuitWith(UnifiedSet.ChainedBucket bucket, Predicate2<? super T, ? super P> predicate, P parameter, boolean expected) private voidchainedTrimToSize(UnifiedSet.ChainedBucket bucket, int oldIndex, int mask) voidclear()clone()booleanReturns true if the iterable has an element which responds true to element.equals(object).private intcopyBucketToArray(Object[] result, UnifiedSet.ChainedBucket bucket, int count) private booleancopyChain(UnifiedSet.ChainedBucket bucket) protected booleancopySet(UnifiedSet<?> unifiedset) private voidcopyToArray(Object[] result) protected TdetectOptional(Predicate<? super T> predicate, int start, int end) voidThe procedure is executed for each element in the iterable.protected voidprivate voidensureCapacity(int size) booleanFollows the same general contract asSet.equals(Object).private intfastCeil(float v) <P> voidforEachWith(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.voidforEachWithIndex(ObjectIntProcedure<? super T> objectIntProcedure) Iterates over the iterable passing each element and the current relative int index to the specified instance of ObjectIntProcedure.Locates an object in the pool which is equal tokey.getFirst()Returns the first element of an iterable.getLast()Returns the last element of an iterable.private TgetLast(UnifiedSet.ChainedBucket bucket) protected Object[]getTable()<V> UnifiedSetMultimap<V, T> 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 toRichIterable.groupBy(Function), except the result of evaluating function will return a collection of keys for each value.inthashCode()Follows the same general contract asSet.hashCode().protected intiterator()newEmpty()Creates a new empty mutable version of the same collection type.newEmpty(int size) 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> static <K> UnifiedSet<K> newSetWith(K... elements) private booleannonNullTableObjectEquals(Object cur, T key) private TnonSentinel(Object key) 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.Putskeyinto the pool.voidprotected voidrehash(int newCapacity) 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 toRichIterable.reject(Predicate), except with an evaluation parameter for the second generic argument inPredicate2.booleanprivate booleanremoveDeepChain(UnifiedSet.ChainedBucket oldBucket, T key) private TremoveDeepChainForPool(UnifiedSet.ChainedBucket oldBucket, T key) private booleanremoveFromChain(UnifiedSet.ChainedBucket bucket, T key, int index) private TremoveFromChainForPool(UnifiedSet.ChainedBucket bucket, T key, int index) removeFromPool(T key) Locates an object in the pool which is equal tokeyand removes it.private booleanretainAllFromNonSet(Iterable<?> iterable) private booleanretainAllFromSet(Set<?> collection) booleanretainAllIterable(Iterable<?> iterable) 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 Classclazz.<P> UnifiedSet<T> selectWith(Predicate2<? super T, ? super P> predicate, P parameter) Similar toRichIterable.select(Predicate), except with an evaluation parameter for the second generic argument inPredicate2.protected booleanshortCircuit(Predicate<? super T> predicate, boolean expected, boolean onShortCircuit, boolean atEnd, int start, int end) protected <P> booleanshortCircuitWith(Predicate2<? super T, ? super P> predicate2, P parameter, boolean expected, boolean onShortCircuit, boolean atEnd) intsize()Returns the number of items in this iterable.Executes the Procedure for each element in the iterable and returnsthis.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.Converts thisMutableCollectionto anImmutableCollection.private static ObjecttoSentinelIfNull(Object key) booleanThis method allows mutable and fixed size collections the ability to add elements to their existing elements.This method allows mutable and fixed size collections the ability to add multiple elements to their existing elements.This method allows mutable and fixed size collections the ability to remove elements from their existing elements.withoutAll(Iterable<? extends T> elements) This method allows mutable and fixed size collections the ability to remove multiple elements from their existing elements.voidprivate voidwriteExternalChain(ObjectOutput out, UnifiedSet.ChainedBucket bucket) Methods inherited from class AbstractUnifiedSet
allocate, allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, asSynchronized, asUnmodifiable, cartesianProduct, chunk, collect, collectIf, collectWith, computeMaxSize, detect, detectOptional, difference, differenceInto, flatCollect, getBatchCount, groupByUniqueKey, init, injectIntoWith, intersect, intersectInto, isProperSubsetOf, isSubsetOf, noneSatisfy, noneSatisfyWith, powerSet, rehash, removeAllIterable, retainAll, shortCircuit, symmetricDifference, symmetricDifferenceInto, union, unionInto, zip, zipWithIndexMethods inherited from class AbstractMutableCollection
addAll, countBy, countByEach, countByWith, reduce, removeAll, removeIf, removeIfWith, sumByDouble, sumByFloat, sumByInt, sumByLongMethods inherited from class AbstractRichIterable
appendString, appendString, asLazy, collect, collectIf, collectWith, containsAll, containsAllArguments, containsAllIterable, count, countWith, 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, toBiMap, toList, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toSortedSetBy, toString, zip, zipWithIndexMethods inherited from interface BatchIterable
forEachMethods inherited from interface Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface InternalIterable
forEachMethods inherited from interface MutableCollection
aggregateBy, aggregateInPlaceBy, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectInt, collectLong, collectShort, countBy, countByEach, countByWith, flatCollectWith, removeIf, removeIfWith, sumByDouble, sumByFloat, sumByInt, sumByLongMethods inherited from interface MutableSet
collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectInt, collectLong, collectShort, flatCollectWith, toImmutableSetMethods inherited from interface RichIterable
aggregateBy, appendString, appendString, appendString, asLazy, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, containsAll, containsAllArguments, containsAllIterable, containsAny, containsAnyIterable, containsBy, containsNone, containsNoneIterable, count, countBy, countByEach, countByWith, countWith, detectIfNone, detectWith, detectWithIfNone, detectWithOptional, flatCollect, flatCollectBoolean, flatCollectByte, flatCollectChar, flatCollectDouble, flatCollectFloat, flatCollectInt, flatCollectLong, flatCollectShort, flatCollectWith, forEach, getAny, getOnly, groupBy, groupByAndCollect, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, injectIntoDouble, injectIntoFloat, injectIntoInt, injectIntoLong, into, isEmpty, makeString, makeString, makeString, makeString, max, max, maxBy, maxByOptional, maxOptional, maxOptional, min, min, minBy, minByOptional, minOptional, minOptional, notEmpty, reduce, reduceBy, reduceBy, reduceInPlace, reduceInPlace, reject, rejectWith, select, selectWith, summarizeDouble, summarizeFloat, summarizeInt, summarizeLong, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toBag, toBiMap, toImmutableBag, toImmutableBiMap, toImmutableList, toImmutableMap, toImmutableSortedBag, toImmutableSortedBag, toImmutableSortedBagBy, toImmutableSortedList, toImmutableSortedList, toImmutableSortedListBy, toImmutableSortedSet, toImmutableSortedSet, toImmutableSortedSetBy, toList, toMap, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toSortedSetBy, toString, zip, zipWithIndexMethods inherited from interface Set
addAll, containsAll, isEmpty, removeAll, spliterator
-
Field Details
-
NULL_KEY
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
table
-
occupied
protected transient int occupied
-
-
Constructor Details
-
UnifiedSet
public UnifiedSet() -
UnifiedSet
public UnifiedSet(int initialCapacity) -
UnifiedSet
public UnifiedSet(int initialCapacity, float loadFactor) -
UnifiedSet
-
UnifiedSet
-
-
Method Details
-
newSet
-
newSet
-
newSet
-
newSet
-
newSetWith
-
fastCeil
private int fastCeil(float v) -
getTable
- Specified by:
getTablein classAbstractUnifiedSet<T>
-
allocateTable
protected void allocateTable(int sizeToAllocate) - Specified by:
allocateTablein classAbstractUnifiedSet<T>
-
index
-
clear
-
add
- Specified by:
addin interfaceCollection<T>- Specified by:
addin interfaceSet<T>- Overrides:
addin classAbstractMutableCollection<T>
-
chainedAdd
-
rehash
protected void rehash(int newCapacity) - Specified by:
rehashin classAbstractUnifiedSet<T>
-
contains
Description copied from interface:RichIterableReturns true if the iterable has an element which responds true to element.equals(object).- Specified by:
containsin interfaceCollection<T>- Specified by:
containsin interfaceRichIterable<T>- Specified by:
containsin interfaceSet<T>- Overrides:
containsin classAbstractRichIterable<T>
-
chainContains
-
batchForEach
- Specified by:
batchForEachin interfaceBatchIterable<T>
-
tap
Description copied from interface:RichIterableExecutes the Procedure for each element in the iterable and returnsthis.Example using a Java 8 lambda expression:
RichIterable<Person> tapped = people.tap(person -> LOGGER.info(person.getName()));- Specified by:
tapin interfaceMutableCollection<T>- Specified by:
tapin interfaceMutableSet<T>- Specified by:
tapin interfaceMutableSetIterable<T>- Specified by:
tapin interfaceRichIterable<T>- Specified by:
tapin interfaceSetIterable<T>- Specified by:
tapin interfaceUnsortedSetIterable<T>- See Also:
-
each
Description copied from interface:RichIterableThe procedure is executed for each element in the iterable.Example using a Java 8 lambda expression:
people.each(person -> LOGGER.info(person.getName()));
This method is a variant ofInternalIterable.forEach(Procedure)that has a signature conflict withIterable.forEach(java.util.function.Consumer).- Specified by:
eachin interfaceRichIterable<T>- See Also:
-
each
-
chainedForEach
-
forEachWith
Description copied from interface:InternalIterableThe procedure2 is evaluated for each element in the iterable with the specified parameter provided as the second argument.Example 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<Person, Person>() { public void value(Person person, Person other) { if (person.isRelatedTo(other)) { LOGGER.info(person.getName()); } } }, fred);- Specified by:
forEachWithin interfaceInternalIterable<T>- Overrides:
forEachWithin classAbstractRichIterable<T>
-
chainedForEachWith
private <P> void chainedForEachWith(UnifiedSet.ChainedBucket bucket, Procedure2<? super T, ? super P> procedure, P parameter) -
forEachWithIndex
Description copied from interface:InternalIterableIterates over the iterable passing each element and the current relative int index to the specified instance of ObjectIntProcedure.Example 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<Person>() { public void value(Person person, int index) { LOGGER.info("Index: " + index + " person: " + person.getName()); } });- Specified by:
forEachWithIndexin interfaceInternalIterable<T>- Overrides:
forEachWithIndexin classAbstractRichIterable<T>
-
chainedForEachWithIndex
private int chainedForEachWithIndex(UnifiedSet.ChainedBucket bucket, ObjectIntProcedure<? super T> procedure, int count) -
newEmpty
Description copied from interface:MutableCollectionCreates a new empty mutable version of the same collection type. For example, if this instance is a FastList, this method will return a new empty FastList. If the class of this instance is immutable or fixed size (i.e. SingletonList) then a mutable alternative to the class will be provided.- Specified by:
newEmptyin interfaceMutableCollection<T>- Specified by:
newEmptyin interfaceMutableSet<T>
-
newEmpty
- Specified by:
newEmptyin classAbstractUnifiedSet<T>
-
getFirst
Description copied from interface:RichIterableReturns the first element of an iterable. In the case of a List it is the element at the first index. In the case of any other Collection, it is the first element that would be returned during an iteration. If the iterable is empty, null is returned. If null is a valid element of the container, then a developer would need to check to see if the iterable is empty to validate that a null result was not due to the container being empty.The 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.
- Specified by:
getFirstin interfaceRichIterable<T>
-
getLast
Description copied from interface:RichIterableReturns the last element of an iterable. In the case of a List it is the element at the last index. In the case of any other Collection, it is the last element that would be returned during an iteration. If the iterable is empty, null is returned. If null is a valid element of the container, then a developer would need to check to see if the iterable is empty to validate that a null result was not due to the container being empty.The 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.
- Specified by:
getLastin interfaceRichIterable<T>
-
getLast
-
select
Description copied from interface:RichIterableReturns all elements of the source collection that return true when evaluating the predicate. This method is also commonly called filter.Example using a Java 8 lambda expression:
RichIterable<Person> selected = people.select(person -> person.getAddress().getCity().equals("London"));- Specified by:
selectin interfaceMutableCollection<T>- Specified by:
selectin interfaceMutableSet<T>- Specified by:
selectin interfaceMutableSetIterable<T>- Specified by:
selectin interfaceRichIterable<T>- Specified by:
selectin interfaceSetIterable<T>- Specified by:
selectin interfaceUnsortedSetIterable<T>
-
selectWith
Description copied from interface:RichIterableSimilar toRichIterable.select(Predicate), except with an evaluation parameter for the second generic argument inPredicate2.E.g. return a
Collectionof Person elements where the person has an age greater than or equal to 18 yearsExample using a Java 8 lambda expression:
RichIterable<Person> selected = people.selectWith((Person person, Integer age) -> person.getAge()>= age, Integer.valueOf(18));- Specified by:
selectWithin interfaceMutableCollection<T>- Specified by:
selectWithin interfaceMutableSet<T>- Specified by:
selectWithin interfaceMutableSetIterable<T>- Specified by:
selectWithin interfaceRichIterable<T>- Specified by:
selectWithin interfaceSetIterable<T>- Specified by:
selectWithin interfaceUnsortedSetIterable<T>- Parameters:
predicate- aPredicate2to use as the select criteriaparameter- a parameter to pass in for evaluation of the second argumentPinpredicate- See Also:
-
reject
Description copied from interface:RichIterableReturns all elements of the source collection that return false when evaluating of the predicate. This method is also sometimes called filterNot and is the equivalent of calling iterable.select(Predicates.not(predicate)).Example using a Java 8 lambda expression:
RichIterable<Person> rejected = people.reject(person -> person.person.getLastName().equals("Smith"));- Specified by:
rejectin interfaceMutableCollection<T>- Specified by:
rejectin interfaceMutableSet<T>- Specified by:
rejectin interfaceMutableSetIterable<T>- Specified by:
rejectin interfaceRichIterable<T>- Specified by:
rejectin interfaceSetIterable<T>- Specified by:
rejectin interfaceUnsortedSetIterable<T>- Parameters:
predicate- aPredicateto use as the reject criteria- Returns:
- a RichIterable that contains elements that cause
Predicate.accept(Object)method to evaluate to false
-
rejectWith
Description copied from interface:RichIterableSimilar toRichIterable.reject(Predicate), except with an evaluation parameter for the second generic argument inPredicate2.E.g. return a
Collectionof Person elements where the person has an age greater than or equal to 18 yearsExample using a Java 8 lambda expression:
RichIterable<Person> rejected = people.rejectWith((Person person, Integer age) -> person.getAge() < age, Integer.valueOf(18));- Specified by:
rejectWithin interfaceMutableCollection<T>- Specified by:
rejectWithin interfaceMutableSet<T>- Specified by:
rejectWithin interfaceMutableSetIterable<T>- Specified by:
rejectWithin interfaceRichIterable<T>- Specified by:
rejectWithin interfaceSetIterable<T>- Specified by:
rejectWithin interfaceUnsortedSetIterable<T>- Parameters:
predicate- aPredicate2to use as the select criteriaparameter- a parameter to pass in for evaluation of the second argumentPinpredicate- See Also:
-
selectAndRejectWith
public <P> Twin<MutableList<T>> selectAndRejectWith(Predicate2<? super T, ? super P> predicate, P parameter) Description copied from interface:MutableCollectionFilters a collection into two separate collections based on a predicate returned via a Pair.e.g. return lastNames.selectAndRejectWith(Predicates2.lessThan(), "Mason");
- Specified by:
selectAndRejectWithin interfaceMutableCollection<T>- Overrides:
selectAndRejectWithin classAbstractMutableCollection<T>
-
partition
Description copied from interface:RichIterableFilters a collection into a PartitionedIterable based on the evaluation of the predicate.Example using a Java 8 lambda expression:
PartitionIterable<Person> newYorkersAndNonNewYorkers = people.partition(person -> person.getAddress().getState().getName().equals("New York"));- Specified by:
partitionin interfaceMutableCollection<T>- Specified by:
partitionin interfaceMutableSet<T>- Specified by:
partitionin interfaceMutableSetIterable<T>- Specified by:
partitionin interfaceRichIterable<T>- Specified by:
partitionin interfaceSetIterable<T>
-
partitionWith
public <P> PartitionMutableSet<T> partitionWith(Predicate2<? super T, ? super P> predicate, P parameter) Description copied from interface:RichIterableFilters a collection into a PartitionIterable based on the evaluation of the predicate.Example using a Java 8 lambda expression:
PartitionIterable<Person> newYorkersAndNonNewYorkers = people.partitionWith((Person person, String state) -> person.getAddress().getState().getName().equals(state), "New York");- Specified by:
partitionWithin interfaceMutableCollection<T>- Specified by:
partitionWithin interfaceMutableSet<T>- Specified by:
partitionWithin interfaceMutableSetIterable<T>- Specified by:
partitionWithin interfaceRichIterable<T>- Specified by:
partitionWithin interfaceSetIterable<T>
-
selectInstancesOf
Description copied from interface:RichIterableReturns all elements of the source collection that are instances of the Classclazz.RichIterable<Integer> integers = List.mutable.with(new Integer(0), new Long(0L), new Double(0.0)).selectInstancesOf(Integer.class);- Specified by:
selectInstancesOfin interfaceMutableCollection<T>- Specified by:
selectInstancesOfin interfaceMutableSet<T>- Specified by:
selectInstancesOfin interfaceMutableSetIterable<T>- Specified by:
selectInstancesOfin interfaceRichIterable<T>- Specified by:
selectInstancesOfin interfaceSetIterable<T>- Specified by:
selectInstancesOfin interfaceUnsortedSetIterable<T>
-
detect
-
detectOptional
- Specified by:
detectOptionalin classAbstractUnifiedSet<T>
-
chainedDetect
-
shortCircuit
protected boolean shortCircuit(Predicate<? super T> predicate, boolean expected, boolean onShortCircuit, boolean atEnd, int start, int end) - Specified by:
shortCircuitin classAbstractUnifiedSet<T>
-
chainedShortCircuit
private boolean chainedShortCircuit(UnifiedSet.ChainedBucket bucket, Predicate<? super T> predicate, boolean expected) -
shortCircuitWith
protected <P> boolean shortCircuitWith(Predicate2<? super T, ? super P> predicate2, P parameter, boolean expected, boolean onShortCircuit, boolean atEnd) - Specified by:
shortCircuitWithin classAbstractUnifiedSet<T>
-
chainedShortCircuitWith
private <P> boolean chainedShortCircuitWith(UnifiedSet.ChainedBucket bucket, Predicate2<? super T, ? super P> predicate, P parameter, boolean expected) -
toImmutable
Description copied from interface:MutableCollectionConverts thisMutableCollectionto anImmutableCollection.- Specified by:
toImmutablein interfaceMutableCollection<T>- Specified by:
toImmutablein interfaceMutableSet<T>- Specified by:
toImmutablein interfaceSetIterable<T>- Specified by:
toImmutablein interfaceUnsortedSetIterable<T>
-
with
Description copied from interface:MutableCollectionThis method allows mutable and fixed size collections the ability to add elements to their existing elements. In order to support fixed size a new instance of a collection would have to be returned taking the elements of the original collection and appending the new element to form the new collection. In the case of mutable collections, the original collection is modified, and is returned. In order to use this method properly with mutable and fixed size collections the following approach must be taken:MutableCollection<String> list = list.with("1"); list = list.with("2"); return list;In the case ofFixedSizeCollectiona 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.- Specified by:
within interfaceMutableCollection<T>- Specified by:
within interfaceMutableSet<T>- Specified by:
within interfaceMutableSetIterable<T>- See Also:
-
with
-
with
-
with
-
withAll
Description copied from interface:MutableCollectionThis method allows mutable and fixed size collections the ability to add multiple elements to their existing elements. In order to support fixed size a new instance of a collection would have to be returned taking the elements of the original collection and appending the new elements to form the new collection. In the case of mutable collections, the original collection is modified, and is returned. In order to use this method properly with mutable and fixed size collections the following approach must be taken:MutableCollection<String> list = list.withAll(FastList.newListWith("1", "2"));In the case ofFixedSizeCollectiona 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.- Specified by:
withAllin interfaceMutableCollection<T>- Specified by:
withAllin interfaceMutableSet<T>- Specified by:
withAllin interfaceMutableSetIterable<T>- See Also:
-
without
Description copied from interface:MutableCollectionThis method allows mutable and fixed size collections the ability to remove elements from their existing elements. In order to support fixed size a new instance of a collection would have to be returned containing the elements that would be left from the original collection after calling remove. In the case of mutable collections, the original collection is modified, and is returned. In order to use this method properly with mutable and fixed size collections the following approach must be taken:MutableCollection<String> list = list.without("1"); list = list.without("2"); return list;In the case ofFixedSizeCollectiona 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.- Specified by:
withoutin interfaceMutableCollection<T>- Specified by:
withoutin interfaceMutableSet<T>- Specified by:
withoutin interfaceMutableSetIterable<T>- See Also:
-
withoutAll
Description copied from interface:MutableCollectionThis method allows mutable and fixed size collections the ability to remove multiple elements from their existing elements. In order to support fixed size a new instance of a collection would have to be returned containing the elements that would be left from the original collection after calling removeAll. In the case of mutable collections, the original collection is modified, and is returned. In order to use this method properly with mutable and fixed size collections the following approach must be taken:MutableCollection<String> list = list.withoutAll(FastList.newListWith("1", "2"));In the case ofFixedSizeCollectiona 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.- Specified by:
withoutAllin interfaceMutableCollection<T>- Specified by:
withoutAllin interfaceMutableSet<T>- Specified by:
withoutAllin interfaceMutableSetIterable<T>- See Also:
-
addAllIterable
- Specified by:
addAllIterablein interfaceMutableCollection<T>- Overrides:
addAllIterablein classAbstractMutableCollection<T>- See Also:
-
ensureCapacity
private void ensureCapacity(int size) -
copySet
-
copyChain
-
remove
- Specified by:
removein interfaceCollection<T>- Specified by:
removein interfaceSet<T>- Overrides:
removein classAbstractMutableCollection<T>
-
removeFromChain
-
removeDeepChain
-
size
public int size()Description copied from interface:RichIterableReturns the number of items in this iterable.- Specified by:
sizein interfaceBatchIterable<T>- Specified by:
sizein interfaceCollection<T>- Specified by:
sizein interfacePool<T>- Specified by:
sizein interfaceRichIterable<T>- Specified by:
sizein interfaceSet<T>
-
equals
Description copied from interface:SetIterableFollows the same general contract asSet.equals(Object). -
hashCode
public int hashCode()Description copied from interface:SetIterableFollows the same general contract asSet.hashCode(). -
chainedHashCode
-
trimToSize
public boolean trimToSize() -
chainedTrimToSize
-
addForTrim
-
chainedAddForTrim
-
readExternal
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
writeExternal
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
writeExternalChain
private void writeExternalChain(ObjectOutput out, UnifiedSet.ChainedBucket bucket) throws IOException - Throws:
IOException
-
addIfFound
-
addIfFoundFromChain
-
retainAllIterable
- Specified by:
retainAllIterablein interfaceMutableCollection<T>- Overrides:
retainAllIterablein classAbstractMutableCollection<T>- See Also:
-
retainAllFromNonSet
-
retainAllFromSet
-
clone
- Specified by:
clonein interfaceMutableSet<T>- Specified by:
clonein classAbstractUnifiedSet<T>
-
toArray
Description copied from interface:RichIterableConverts this iterable to an array.- Specified by:
toArrayin interfaceCollection<T>- Specified by:
toArrayin interfaceMutableCollection<T>- Specified by:
toArrayin interfaceMutableSetIterable<T>- Specified by:
toArrayin interfaceRichIterable<T>- Specified by:
toArrayin interfaceSet<T>- See Also:
-
copyToArray
-
copyBucketToArray
-
toArray
public <T> T[] toArray(T[] array) Description copied from interface:RichIterableConverts this iterable to an array using the specified target array, assuming the target array is as long or longer than the iterable.- Specified by:
toArrayin interfaceCollection<T>- Specified by:
toArrayin interfaceMutableCollection<T>- Specified by:
toArrayin interfaceMutableSetIterable<T>- Specified by:
toArrayin interfaceRichIterable<T>- Specified by:
toArrayin interfaceSet<T>- See Also:
-
iterator
-
groupBy
Description copied from interface:RichIterableFor 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.Example using a Java 8 method reference:
Multimap<String, Person> peopleByLastName = people.groupBy(Person::getLastName);- Specified by:
groupByin interfaceMutableCollection<T>- Specified by:
groupByin interfaceMutableSet<T>- Specified by:
groupByin interfaceMutableSetIterable<T>- Specified by:
groupByin interfaceRichIterable<T>- Specified by:
groupByin interfaceUnsortedSetIterable<T>
-
groupByEach
Description copied from interface:RichIterableSimilar toRichIterable.groupBy(Function), except the result of evaluating function will return a collection of keys for each value.- Specified by:
groupByEachin interfaceMutableCollection<T>- Specified by:
groupByEachin interfaceMutableSet<T>- Specified by:
groupByEachin interfaceMutableSetIterable<T>- Specified by:
groupByEachin interfaceRichIterable<T>- Specified by:
groupByEachin interfaceUnsortedSetIterable<T>
-
get
-
chainedGet
-
put
Description copied from interface:PoolPutskeyinto 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 tokey, the pool will remain unchanged and the pooled instance will be is returned. -
chainedPut
-
removeFromPool
-
removeFromChainForPool
-
removeDeepChainForPool
-
nonSentinel
-
toSentinelIfNull
-
nonNullTableObjectEquals
-
asParallel
Description copied from interface:SetIterableReturns a parallel iterable of this SetIterable.- Specified by:
asParallelin interfaceSetIterable<T>- Specified by:
asParallelin interfaceUnsortedSetIterable<T>
-