Class UnifiedSetWithHashingStrategy<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>
public class UnifiedSetWithHashingStrategy<T> extends AbstractUnifiedSet<T> implements Externalizable
- See Also:
- Serialized Form
-
Constructor Summary
Constructors Constructor Description UnifiedSetWithHashingStrategy()
Deprecated.No argument default constructor used for serialization.UnifiedSetWithHashingStrategy(HashingStrategy<? super T> hashingStrategy)
UnifiedSetWithHashingStrategy(HashingStrategy<? super T> hashingStrategy, int initialCapacity)
UnifiedSetWithHashingStrategy(HashingStrategy<? super T> hashingStrategy, int initialCapacity, float loadFactor)
UnifiedSetWithHashingStrategy(HashingStrategy<? super T> hashingStrategy, Collection<? extends T> collection)
UnifiedSetWithHashingStrategy(HashingStrategy<? super T> hashingStrategy, UnifiedSetWithHashingStrategy<T> set)
-
Method Summary
Modifier and Type Method Description boolean
add(T key)
boolean
addAllIterable(Iterable<? extends T> iterable)
T
addOrReplace(T key)
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()
UnifiedSetWithHashingStrategy<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 asSet.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 tokey
.T
getFirst()
Returns the first element of an iterable.T
getLast()
Returns the last element of an iterable.<V> UnifiedSetWithHashingStrategyMultimap<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> UnifiedSetWithHashingStrategyMultimap<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.int
hashCode()
Follows the same general contract asSet.hashCode()
.HashingStrategy<? super T>
hashingStrategy()
Iterator<T>
iterator()
<V> LazyIterable<V>
lazyCollect(Function<? super T,? extends V> function)
Deprecated.since 3.0.LazyIterable<T>
lazyReject(Predicate<? super T> predicate)
Deprecated.since 3.0.LazyIterable<T>
lazySelect(Predicate<? super T> predicate)
Deprecated.since 3.0.UnifiedSetWithHashingStrategy<T>
newEmpty()
Creates a new empty mutable version of the same collection type.UnifiedSetWithHashingStrategy<T>
newEmpty(int size)
static <K> UnifiedSetWithHashingStrategy<K>
newSet(HashingStrategy<? super K> hashingStrategy)
static <K> UnifiedSetWithHashingStrategy<K>
newSet(HashingStrategy<? super K> hashingStrategy, int size)
static <K> UnifiedSetWithHashingStrategy<K>
newSet(HashingStrategy<? super K> hashingStrategy, int size, float loadFactor)
static <K> UnifiedSetWithHashingStrategy<K>
newSet(HashingStrategy<? super K> hashingStrategy, Iterable<? extends K> source)
static <K> UnifiedSetWithHashingStrategy<K>
newSet(UnifiedSetWithHashingStrategy<K> set)
static <K> UnifiedSetWithHashingStrategy<K>
newSetWith(HashingStrategy<? super K> hashingStrategy, 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)
Putskey
into the pool.void
readExternal(ObjectInput in)
UnifiedSetWithHashingStrategy<T>
reject(Predicate<? super T> predicate)
Returns all elements of the source collection that return false when evaluating of the predicate.<P> UnifiedSetWithHashingStrategy<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
.boolean
remove(Object key)
T
removeFromPool(T key)
Locates an object in the pool which is equal tokey
and removes it.boolean
retainAllIterable(Iterable<?> iterable)
UnifiedSetWithHashingStrategy<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> UnifiedSetWithHashingStrategy<S>
selectInstancesOf(Class<S> clazz)
Returns all elements of the source collection that are instances of the Classclazz
.<P> UnifiedSetWithHashingStrategy<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
.int
size()
Returns the number of items in this iterable.UnifiedSetWithHashingStrategy<T>
tap(Procedure<? super T> procedure)
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.ImmutableSet<T>
toImmutable()
Returns an immutable copy of this set.boolean
trimToSize()
UnifiedSetWithHashingStrategy<T>
with(T element)
This method allows mutable and fixed size collections the ability to add elements to their existing elements.UnifiedSetWithHashingStrategy<T>
with(T... elements)
UnifiedSetWithHashingStrategy<T>
with(T element1, T element2)
UnifiedSetWithHashingStrategy<T>
with(T element1, T element2, T element3)
UnifiedSetWithHashingStrategy<T>
withAll(Iterable<? extends T> iterable)
This method allows mutable and fixed size collections the ability to add multiple elements to their existing elements.UnifiedSetWithHashingStrategy<T>
without(T element)
This method allows mutable and fixed size collections the ability to remove elements from their existing elements.UnifiedSetWithHashingStrategy<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)
Methods inherited from class org.eclipse.collections.impl.set.AbstractUnifiedSet
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, zipWithIndex
Methods inherited from class org.eclipse.collections.impl.collection.mutable.AbstractMutableCollection
addAll, aggregateInPlaceBy, countBy, countByEach, countByWith, reduce, removeAll, removeIf, removeIfWith, sumByDouble, sumByFloat, sumByInt, sumByLong
Methods inherited from class org.eclipse.collections.impl.AbstractRichIterable
appendString, appendString, asLazy, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, 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, zipWithIndex
Methods inherited from interface org.eclipse.collections.api.collection.MutableCollection
aggregateBy, aggregateInPlaceBy, countBy, countByEach, countByWith, flatCollectWith, removeIf, removeIfWith, sumByDouble, sumByFloat, sumByInt, sumByLong
Methods inherited from interface org.eclipse.collections.api.RichIterable
aggregateBy, appendString, appendString, appendString, asLazy, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, containsAll, containsAllArguments, containsAllIterable, containsBy, 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, into, isEmpty, makeString, makeString, makeString, max, max, maxBy, maxByOptional, maxOptional, maxOptional, min, min, minBy, minByOptional, minOptional, minOptional, notEmpty, reduce, reduceInPlace, reduceInPlace, reject, rejectWith, select, selectWith, summarizeDouble, summarizeFloat, summarizeInt, summarizeLong, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toBag, toBiMap, toList, toMap, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toSortedSetBy, toString, zip, zipWithIndex
-
Constructor Details
-
UnifiedSetWithHashingStrategy
Deprecated.No argument default constructor used for serialization. Instantiating an UnifiedSetWithHashingStrategyMultimap with this constructor will have a null hashingStrategy and throw NullPointerException when used. -
UnifiedSetWithHashingStrategy
-
UnifiedSetWithHashingStrategy
public UnifiedSetWithHashingStrategy(HashingStrategy<? super T> hashingStrategy, int initialCapacity) -
UnifiedSetWithHashingStrategy
public UnifiedSetWithHashingStrategy(HashingStrategy<? super T> hashingStrategy, int initialCapacity, float loadFactor) -
UnifiedSetWithHashingStrategy
public UnifiedSetWithHashingStrategy(HashingStrategy<? super T> hashingStrategy, Collection<? extends T> collection) -
UnifiedSetWithHashingStrategy
public UnifiedSetWithHashingStrategy(HashingStrategy<? super T> hashingStrategy, UnifiedSetWithHashingStrategy<T> set)
-
-
Method Details
-
newSet
public static <K> UnifiedSetWithHashingStrategy<K> newSet(HashingStrategy<? super K> hashingStrategy) -
newSet
-
newSet
public static <K> UnifiedSetWithHashingStrategy<K> newSet(HashingStrategy<? super K> hashingStrategy, int size) -
newSet
public static <K> UnifiedSetWithHashingStrategy<K> newSet(HashingStrategy<? super K> hashingStrategy, Iterable<? extends K> source) -
newSet
public static <K> UnifiedSetWithHashingStrategy<K> newSet(HashingStrategy<? super K> hashingStrategy, int size, float loadFactor) -
newSetWith
public static <K> UnifiedSetWithHashingStrategy<K> newSetWith(HashingStrategy<? super K> hashingStrategy, K... elements) -
hashingStrategy
-
clear
public void clear() -
add
- Specified by:
add
in interfaceCollection<T>
- Specified by:
add
in interfaceSet<T>
- Overrides:
add
in classAbstractMutableCollection<T>
-
addOrReplace
-
contains
Description copied from interface:RichIterable
Returns true if the iterable has an element which responds true to element.equals(object).- Specified by:
contains
in interfaceCollection<T>
- Specified by:
contains
in interfaceRichIterable<T>
- Specified by:
contains
in interfaceSet<T>
- Overrides:
contains
in classAbstractRichIterable<T>
-
batchForEach
- Specified by:
batchForEach
in interfaceBatchIterable<T>
-
tap
Description copied from interface:RichIterable
Executes 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()));
Example using an anonymous inner class:
RichIterable<Person> tapped = people.tap(new Procedure<Person>() { public void value(Person person) { LOGGER.info(person.getName()); } });
- Specified by:
tap
in interfaceMutableCollection<T>
- Specified by:
tap
in interfaceMutableSet<T>
- Specified by:
tap
in interfaceMutableSetIterable<T>
- Specified by:
tap
in interfaceRichIterable<T>
- Specified by:
tap
in interfaceSetIterable<T>
- Specified by:
tap
in interfaceUnsortedSetIterable<T>
- See Also:
RichIterable.each(Procedure)
,RichIterable.forEach(Procedure)
-
each
Description copied from interface:RichIterable
The procedure is executed for each element in the iterable.Example using a Java 8 lambda expression:
people.each(person -> LOGGER.info(person.getName()));
Example using an anonymous inner class:
people.each(new Procedure<Person>() { public void value(Person 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:
each
in interfaceRichIterable<T>
- See Also:
InternalIterable.forEach(Procedure)
,Iterable.forEach(java.util.function.Consumer)
-
forEachWith
Description copied from interface:InternalIterable
The 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:
forEachWith
in interfaceInternalIterable<T>
- Overrides:
forEachWith
in classAbstractRichIterable<T>
-
forEachWithIndex
Description copied from interface:InternalIterable
Iterates 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:
forEachWithIndex
in interfaceInternalIterable<T>
- Overrides:
forEachWithIndex
in classAbstractRichIterable<T>
-
newEmpty
Description copied from interface:MutableCollection
Creates 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:
newEmpty
in interfaceMutableCollection<T>
- Specified by:
newEmpty
in interfaceMutableSet<T>
-
newEmpty
- Specified by:
newEmpty
in classAbstractUnifiedSet<T>
-
getFirst
Description copied from interface:RichIterable
Returns 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:
getFirst
in interfaceRichIterable<T>
-
getLast
Description copied from interface:RichIterable
Returns 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:
getLast
in interfaceRichIterable<T>
-
select
Description copied from interface:RichIterable
Returns 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"));
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"); } });
- Specified by:
select
in interfaceMutableCollection<T>
- Specified by:
select
in interfaceMutableSet<T>
- Specified by:
select
in interfaceMutableSetIterable<T>
- Specified by:
select
in interfaceRichIterable<T>
- Specified by:
select
in interfaceSetIterable<T>
- Specified by:
select
in interfaceUnsortedSetIterable<T>
-
selectWith
public <P> UnifiedSetWithHashingStrategy<T> selectWith(Predicate2<? super T,? super P> predicate, P parameter)Description copied from interface:RichIterable
Similar toRichIterable.select(Predicate)
, except with an evaluation parameter for the second generic argument inPredicate2
.E.g. return a
Collection
of 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));
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));
- Specified by:
selectWith
in interfaceMutableCollection<T>
- Specified by:
selectWith
in interfaceMutableSet<T>
- Specified by:
selectWith
in interfaceMutableSetIterable<T>
- Specified by:
selectWith
in interfaceRichIterable<T>
- Specified by:
selectWith
in interfaceSetIterable<T>
- Specified by:
selectWith
in interfaceUnsortedSetIterable<T>
- Parameters:
predicate
- aPredicate2
to use as the select criteriaparameter
- a parameter to pass in for evaluation of the second argumentP
inpredicate
- See Also:
RichIterable.select(Predicate)
-
reject
Description copied from interface:RichIterable
Returns 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"));
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"); } });
- Specified by:
reject
in interfaceMutableCollection<T>
- Specified by:
reject
in interfaceMutableSet<T>
- Specified by:
reject
in interfaceMutableSetIterable<T>
- Specified by:
reject
in interfaceRichIterable<T>
- Specified by:
reject
in interfaceSetIterable<T>
- Specified by:
reject
in interfaceUnsortedSetIterable<T>
- Parameters:
predicate
- aPredicate
to use as the reject criteria- Returns:
- a RichIterable that contains elements that cause
Predicate.accept(Object)
method to evaluate to false
-
rejectWith
public <P> UnifiedSetWithHashingStrategy<T> rejectWith(Predicate2<? super T,? super P> predicate, P parameter)Description copied from interface:RichIterable
Similar toRichIterable.reject(Predicate)
, except with an evaluation parameter for the second generic argument inPredicate2
.E.g. return a
Collection
of 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));
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));
- Specified by:
rejectWith
in interfaceMutableCollection<T>
- Specified by:
rejectWith
in interfaceMutableSet<T>
- Specified by:
rejectWith
in interfaceMutableSetIterable<T>
- Specified by:
rejectWith
in interfaceRichIterable<T>
- Specified by:
rejectWith
in interfaceSetIterable<T>
- Specified by:
rejectWith
in interfaceUnsortedSetIterable<T>
- Parameters:
predicate
- aPredicate2
to use as the select criteriaparameter
- a parameter to pass in for evaluation of the second argumentP
inpredicate
- See Also:
RichIterable.select(Predicate)
-
selectAndRejectWith
public <P> Twin<MutableList<T>> selectAndRejectWith(Predicate2<? super T,? super P> predicate, P parameter)Description copied from interface:MutableCollection
Filters a collection into two separate collections based on a predicate returned via a Pair.e.g. return lastNames.selectAndRejectWith(Predicates2.lessThan(), "Mason");
- Specified by:
selectAndRejectWith
in interfaceMutableCollection<T>
- Overrides:
selectAndRejectWith
in classAbstractMutableCollection<T>
-
partition
Description copied from interface:RichIterable
Filters 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"));
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"); } });
- Specified by:
partition
in interfaceMutableCollection<T>
- Specified by:
partition
in interfaceMutableSet<T>
- Specified by:
partition
in interfaceMutableSetIterable<T>
- Specified by:
partition
in interfaceRichIterable<T>
- Specified by:
partition
in interfaceSetIterable<T>
-
partitionWith
public <P> PartitionMutableSet<T> partitionWith(Predicate2<? super T,? super P> predicate, P parameter)Description copied from interface:RichIterable
Filters 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");
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");
- Specified by:
partitionWith
in interfaceMutableCollection<T>
- Specified by:
partitionWith
in interfaceMutableSet<T>
- Specified by:
partitionWith
in interfaceMutableSetIterable<T>
- Specified by:
partitionWith
in interfaceRichIterable<T>
- Specified by:
partitionWith
in interfaceSetIterable<T>
-
selectInstancesOf
Description copied from interface:RichIterable
Returns 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:
selectInstancesOf
in interfaceMutableCollection<T>
- Specified by:
selectInstancesOf
in interfaceMutableSet<T>
- Specified by:
selectInstancesOf
in interfaceMutableSetIterable<T>
- Specified by:
selectInstancesOf
in interfaceRichIterable<T>
- Specified by:
selectInstancesOf
in interfaceSetIterable<T>
- Specified by:
selectInstancesOf
in interfaceUnsortedSetIterable<T>
-
lazySelect
Deprecated.since 3.0. UseAbstractRichIterable.asLazy()
.select(Predicate)
instead. -
lazyReject
Deprecated.since 3.0. UseAbstractRichIterable.asLazy()
.reject(Predicate)
instead. -
lazyCollect
Deprecated.since 3.0. UseAbstractRichIterable.asLazy()
.AbstractUnifiedSet.collect(Function)
instead. -
toImmutable
Description copied from interface:MutableSet
Returns an immutable copy of this set. If the set is immutable, it returns itself.- Specified by:
toImmutable
in interfaceMutableCollection<T>
- Specified by:
toImmutable
in interfaceMutableSet<T>
- Specified by:
toImmutable
in interfaceSetIterable<T>
- Specified by:
toImmutable
in interfaceUnsortedSetIterable<T>
-
with
Description copied from interface:MutableCollection
This 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 ofFixedSizeCollection
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.- Specified by:
with
in interfaceMutableCollection<T>
- Specified by:
with
in interfaceMutableSet<T>
- Specified by:
with
in interfaceMutableSetIterable<T>
- See Also:
Collection.add(Object)
-
with
-
with
-
with
-
withAll
Description copied from interface:MutableCollection
This 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 ofFixedSizeCollection
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.- Specified by:
withAll
in interfaceMutableCollection<T>
- Specified by:
withAll
in interfaceMutableSet<T>
- Specified by:
withAll
in interfaceMutableSetIterable<T>
- See Also:
Collection.addAll(Collection)
-
without
Description copied from interface:MutableCollection
This 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 ofFixedSizeCollection
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.- Specified by:
without
in interfaceMutableCollection<T>
- Specified by:
without
in interfaceMutableSet<T>
- Specified by:
without
in interfaceMutableSetIterable<T>
- See Also:
Collection.remove(Object)
-
withoutAll
Description copied from interface:MutableCollection
This 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 ofFixedSizeCollection
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.- Specified by:
withoutAll
in interfaceMutableCollection<T>
- Specified by:
withoutAll
in interfaceMutableSet<T>
- Specified by:
withoutAll
in interfaceMutableSetIterable<T>
- See Also:
Collection.removeAll(Collection)
-
addAllIterable
- Specified by:
addAllIterable
in interfaceMutableCollection<T>
- Overrides:
addAllIterable
in classAbstractMutableCollection<T>
- See Also:
Collection.addAll(Collection)
-
remove
- Specified by:
remove
in interfaceCollection<T>
- Specified by:
remove
in interfaceSet<T>
- Overrides:
remove
in classAbstractMutableCollection<T>
-
size
public int size()Description copied from interface:RichIterable
Returns the number of items in this iterable.- Specified by:
size
in interfaceBatchIterable<T>
- Specified by:
size
in interfaceCollection<T>
- Specified by:
size
in interfacePool<T>
- Specified by:
size
in interfaceRichIterable<T>
- Specified by:
size
in interfaceSet<T>
-
equals
Description copied from interface:SetIterable
Follows the same general contract asSet.equals(Object)
. -
hashCode
public int hashCode()Description copied from interface:SetIterable
Follows the same general contract asSet.hashCode()
. -
trimToSize
public boolean trimToSize() -
readExternal
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
ClassNotFoundException
-
writeExternal
- Specified by:
writeExternal
in interfaceExternalizable
- Throws:
IOException
-
retainAllIterable
- Specified by:
retainAllIterable
in interfaceMutableCollection<T>
- Overrides:
retainAllIterable
in classAbstractMutableCollection<T>
- See Also:
Collection.retainAll(Collection)
-
clone
- Specified by:
clone
in interfaceMutableSet<T>
- Specified by:
clone
in classAbstractUnifiedSet<T>
-
toArray
Description copied from interface:RichIterable
Converts this iterable to an array.- Specified by:
toArray
in interfaceCollection<T>
- Specified by:
toArray
in interfaceRichIterable<T>
- Specified by:
toArray
in interfaceSet<T>
- Overrides:
toArray
in classAbstractRichIterable<T>
- See Also:
Collection.toArray()
-
toArray
public <T> T[] toArray(T[] array)Description copied from interface:RichIterable
Converts this iterable to an array using the specified target array, assuming the target array is as long or longer than the iterable.- Specified by:
toArray
in interfaceCollection<T>
- Specified by:
toArray
in interfaceRichIterable<T>
- Specified by:
toArray
in interfaceSet<T>
- Overrides:
toArray
in classAbstractRichIterable<T>
- See Also:
Collection.toArray(Object[])
-
iterator
-
groupBy
public <V> UnifiedSetWithHashingStrategyMultimap<V,T> groupBy(Function<? super T,? extends V> function)Description copied from interface:RichIterable
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.Example 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(); } });
- Specified by:
groupBy
in interfaceMutableCollection<T>
- Specified by:
groupBy
in interfaceMutableSet<T>
- Specified by:
groupBy
in interfaceMutableSetIterable<T>
- Specified by:
groupBy
in interfaceRichIterable<T>
- Specified by:
groupBy
in interfaceUnsortedSetIterable<T>
-
groupByEach
public <V> UnifiedSetWithHashingStrategyMultimap<V,T> groupByEach(Function<? super T,? extends Iterable<V>> function)Description copied from interface:RichIterable
Similar toRichIterable.groupBy(Function)
, except the result of evaluating function will return a collection of keys for each value.- Specified by:
groupByEach
in interfaceMutableCollection<T>
- Specified by:
groupByEach
in interfaceMutableSet<T>
- Specified by:
groupByEach
in interfaceMutableSetIterable<T>
- Specified by:
groupByEach
in interfaceRichIterable<T>
- Specified by:
groupByEach
in interfaceUnsortedSetIterable<T>
-
get
Description copied from interface:Pool
Locates an object in the pool which is equal tokey
. -
put
Description copied from interface:Pool
Putskey
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 tokey
, the pool will remain unchanged and the pooled instance will be is returned. -
removeFromPool
Description copied from interface:Pool
Locates an object in the pool which is equal tokey
and removes it.- Specified by:
removeFromPool
in interfacePool<T>
- Parameters:
key
- object to remove- Returns:
- The object reference in the pool equal to key or null.
-
asParallel
Description copied from interface:SetIterable
Returns a parallel iterable of this SetIterable.- Specified by:
asParallel
in interfaceSetIterable<T>
- Specified by:
asParallel
in interfaceUnsortedSetIterable<T>
-