@NotThreadSafe public class UnifiedSetWithHashingStrategy<T> extends AbstractUnifiedSet<T> implements java.io.Externalizable
| Modifier and Type | Class and Description |
|---|---|
protected class |
UnifiedSetWithHashingStrategy.PositionalIterator |
| Modifier and Type | Field and Description |
|---|---|
protected static java.lang.Object |
NULL_KEY |
protected int |
occupied |
protected java.lang.Object[] |
table |
DEFAULT_INITIAL_CAPACITY, DEFAULT_LOAD_FACTOR, loadFactor, maxSize| Constructor and Description |
|---|
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(com.gs.collections.api.block.HashingStrategy<? super T> hashingStrategy) |
UnifiedSetWithHashingStrategy(com.gs.collections.api.block.HashingStrategy<? super T> hashingStrategy,
java.util.Collection<? extends T> collection) |
UnifiedSetWithHashingStrategy(com.gs.collections.api.block.HashingStrategy<? super T> hashingStrategy,
int initialCapacity) |
UnifiedSetWithHashingStrategy(com.gs.collections.api.block.HashingStrategy<? super T> hashingStrategy,
int initialCapacity,
float loadFactor) |
UnifiedSetWithHashingStrategy(com.gs.collections.api.block.HashingStrategy<? super T> hashingStrategy,
UnifiedSetWithHashingStrategy<T> set) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(T key) |
boolean |
addAllIterable(java.lang.Iterable<? extends T> iterable) |
protected void |
allocateTable(int sizeToAllocate) |
com.gs.collections.api.set.ParallelUnsortedSetIterable<T> |
asParallel(java.util.concurrent.ExecutorService executorService,
int batchSize)
Returns a parallel iterable of this SetIterable.
|
void |
batchForEach(com.gs.collections.api.block.procedure.Procedure<? super T> procedure,
int sectionIndex,
int sectionCount) |
void |
clear() |
UnifiedSetWithHashingStrategy<T> |
clone() |
boolean |
contains(java.lang.Object key)
Returns true if the iterable has an element which responds true to element.equals(object).
|
protected boolean |
copySet(UnifiedSetWithHashingStrategy<?> unifiedset) |
protected T |
detect(com.gs.collections.api.block.predicate.Predicate<? super T> predicate,
int start,
int end) |
void |
each(com.gs.collections.api.block.procedure.Procedure<? super T> procedure)
The procedure is executed for each element in the iterable.
|
boolean |
equals(java.lang.Object object)
Follows the same general contract as
Set.equals(Object). |
<P> void |
forEachWith(com.gs.collections.api.block.procedure.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(com.gs.collections.api.block.procedure.primitive.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.
|
protected java.lang.Object[] |
getTable() |
<V> UnifiedSetWithHashingStrategyMultimap<V,T> |
groupBy(com.gs.collections.api.block.function.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(com.gs.collections.api.block.function.Function<? super T,? extends java.lang.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(). |
com.gs.collections.api.block.HashingStrategy<? super T> |
hashingStrategy() |
protected int |
index(T key) |
java.util.Iterator<T> |
iterator() |
<V> com.gs.collections.api.LazyIterable<V> |
lazyCollect(com.gs.collections.api.block.function.Function<? super T,? extends V> function)
Deprecated.
since 3.0. Use
AbstractRichIterable.asLazy().AbstractUnifiedSet.collect(Function) instead. |
com.gs.collections.api.LazyIterable<T> |
lazyReject(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
Deprecated.
since 3.0. Use
AbstractRichIterable.asLazy().reject(Predicate) instead. |
com.gs.collections.api.LazyIterable<T> |
lazySelect(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
Deprecated.
since 3.0. Use
AbstractRichIterable.asLazy().select(Predicate) instead. |
UnifiedSetWithHashingStrategy<T> |
newEmpty()
Creates a new empty mutable version of the same collection type.
|
static <K> UnifiedSetWithHashingStrategy<K> |
newSet(com.gs.collections.api.block.HashingStrategy<? super K> hashingStrategy) |
static <K> UnifiedSetWithHashingStrategy<K> |
newSet(com.gs.collections.api.block.HashingStrategy<? super K> hashingStrategy,
int size) |
static <K> UnifiedSetWithHashingStrategy<K> |
newSet(com.gs.collections.api.block.HashingStrategy<? super K> hashingStrategy,
int size,
float loadFactor) |
static <K> UnifiedSetWithHashingStrategy<K> |
newSet(com.gs.collections.api.block.HashingStrategy<? super K> hashingStrategy,
java.lang.Iterable<? extends K> source) |
static <K> UnifiedSetWithHashingStrategy<K> |
newSet(UnifiedSetWithHashingStrategy<K> set) |
static <K> UnifiedSetWithHashingStrategy<K> |
newSetWith(com.gs.collections.api.block.HashingStrategy<? super K> hashingStrategy,
K... elements) |
com.gs.collections.api.partition.set.PartitionMutableSet<T> |
partition(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
Filters a collection into a PartitionedIterable based on the evaluation of the predicate.
|
<P> com.gs.collections.api.partition.set.PartitionMutableSet<T> |
partitionWith(com.gs.collections.api.block.predicate.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
key into the pool. |
void |
readExternal(java.io.ObjectInput in) |
protected void |
rehash(int newCapacity) |
UnifiedSetWithHashingStrategy<T> |
reject(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
Returns all elements of the source collection that return false when evaluating of the predicate.
|
<P> UnifiedSetWithHashingStrategy<T> |
rejectWith(com.gs.collections.api.block.predicate.Predicate2<? super T,? super P> predicate,
P parameter)
Similar to
RichIterable.reject(Predicate), except with an evaluation parameter for the second generic argument in Predicate2. |
boolean |
remove(java.lang.Object key) |
T |
removeFromPool(T key)
Locates an object in the pool which is equal to
key and removes it. |
boolean |
retainAllIterable(java.lang.Iterable<?> iterable) |
UnifiedSetWithHashingStrategy<T> |
select(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
Returns all elements of the source collection that return true when evaluating the predicate.
|
<P> com.gs.collections.api.tuple.Twin<com.gs.collections.api.list.MutableList<T>> |
selectAndRejectWith(com.gs.collections.api.block.predicate.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(java.lang.Class<S> clazz)
Returns all elements of the source collection that are instances of the Class
clazz. |
<P> UnifiedSetWithHashingStrategy<T> |
selectWith(com.gs.collections.api.block.predicate.Predicate2<? super T,? super P> predicate,
P parameter)
Similar to
RichIterable.select(Predicate), except with an evaluation parameter for the second generic argument in Predicate2. |
protected boolean |
shortCircuit(com.gs.collections.api.block.predicate.Predicate<? super T> predicate,
boolean expected,
boolean onShortCircuit,
boolean atEnd,
int start,
int end) |
protected <P> boolean |
shortCircuitWith(com.gs.collections.api.block.predicate.Predicate2<? super T,? super P> predicate2,
P parameter,
boolean expected,
boolean onShortCircuit,
boolean atEnd) |
int |
size()
Returns the number of items in this iterable.
|
UnifiedSetWithHashingStrategy<T> |
tap(com.gs.collections.api.block.procedure.Procedure<? super T> procedure)
Executes the Procedure for each element in the iterable and returns
this. |
java.lang.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.
|
com.gs.collections.api.set.ImmutableSet<T> |
toImmutable()
Returns an immutable copy of this set.
|
UnifiedSetWithHashingStrategy<T> |
with(T... elements) |
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 element1,
T element2) |
UnifiedSetWithHashingStrategy<T> |
with(T element1,
T element2,
T element3) |
UnifiedSetWithHashingStrategy<T> |
withAll(java.lang.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(java.lang.Iterable<? extends T> elements)
This method allows mutable and fixed size collections the ability to remove multiple elements from their existing
elements.
|
void |
writeExternal(java.io.ObjectOutput out) |
addAll, aggregateBy, aggregateInPlaceBy, allocate, allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, asSynchronized, asUnmodifiable, cartesianProduct, chunk, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, computeMaxSize, detect, difference, differenceInto, flatCollect, getBatchCount, groupByUniqueKey, init, injectIntoWith, intersect, intersectInto, isProperSubsetOf, isSubsetOf, noneSatisfy, noneSatisfyWith, powerSet, rehash, removeAll, removeAllIterable, removeIf, removeIfWith, retainAll, shortCircuit, symmetricDifference, symmetricDifferenceInto, union, unionInto, zip, zipWithIndexappendString, appendString, appendString, asLazy, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, containsAll, containsAllArguments, containsAllIterable, count, countWith, detectIfNone, detectWith, detectWithIfNone, flatCollect, forEach, groupBy, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, isEmpty, makeString, makeString, makeString, max, max, maxBy, min, min, minBy, notEmpty, reject, rejectWith, select, selectWith, sumByDouble, sumByFloat, sumByInt, sumByLong, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toBag, toList, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedSet, toSortedSet, toSortedSetBy, toString, zip, zipWithIndexfinalize, getClass, notify, notifyAll, wait, wait, waitappendString, appendString, appendString, asLazy, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, containsAll, containsAllArguments, containsAllIterable, count, countWith, detectIfNone, detectWith, detectWithIfNone, flatCollect, groupBy, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, isEmpty, makeString, makeString, makeString, max, max, maxBy, min, min, minBy, notEmpty, reject, rejectWith, select, selectWith, sumByDouble, sumByFloat, sumByInt, sumByLong, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toBag, toList, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedSet, toSortedSet, toSortedSetBy, toString, zip, zipWithIndexforEachprotected static final java.lang.Object NULL_KEY
protected transient java.lang.Object[] table
protected transient int occupied
@Deprecated public UnifiedSetWithHashingStrategy()
public UnifiedSetWithHashingStrategy(com.gs.collections.api.block.HashingStrategy<? super T> hashingStrategy)
public UnifiedSetWithHashingStrategy(com.gs.collections.api.block.HashingStrategy<? super T> hashingStrategy, int initialCapacity)
public UnifiedSetWithHashingStrategy(com.gs.collections.api.block.HashingStrategy<? super T> hashingStrategy, int initialCapacity, float loadFactor)
public UnifiedSetWithHashingStrategy(com.gs.collections.api.block.HashingStrategy<? super T> hashingStrategy, java.util.Collection<? extends T> collection)
public UnifiedSetWithHashingStrategy(com.gs.collections.api.block.HashingStrategy<? super T> hashingStrategy, UnifiedSetWithHashingStrategy<T> set)
public static <K> UnifiedSetWithHashingStrategy<K> newSet(com.gs.collections.api.block.HashingStrategy<? super K> hashingStrategy)
public static <K> UnifiedSetWithHashingStrategy<K> newSet(UnifiedSetWithHashingStrategy<K> set)
public static <K> UnifiedSetWithHashingStrategy<K> newSet(com.gs.collections.api.block.HashingStrategy<? super K> hashingStrategy, int size)
public static <K> UnifiedSetWithHashingStrategy<K> newSet(com.gs.collections.api.block.HashingStrategy<? super K> hashingStrategy, java.lang.Iterable<? extends K> source)
public static <K> UnifiedSetWithHashingStrategy<K> newSet(com.gs.collections.api.block.HashingStrategy<? super K> hashingStrategy, int size, float loadFactor)
public static <K> UnifiedSetWithHashingStrategy<K> newSetWith(com.gs.collections.api.block.HashingStrategy<? super K> hashingStrategy, K... elements)
public com.gs.collections.api.block.HashingStrategy<? super T> hashingStrategy()
protected java.lang.Object[] getTable()
getTable in class AbstractUnifiedSet<T>protected void allocateTable(int sizeToAllocate)
allocateTable in class AbstractUnifiedSet<T>protected final int index(T key)
public void clear()
public boolean add(T key)
protected void rehash(int newCapacity)
rehash in class AbstractUnifiedSet<T>public boolean contains(java.lang.Object key)
com.gs.collections.api.RichIterablepublic void batchForEach(com.gs.collections.api.block.procedure.Procedure<? super T> procedure, int sectionIndex, int sectionCount)
batchForEach in interface BatchIterable<T>public UnifiedSetWithHashingStrategy<T> tap(com.gs.collections.api.block.procedure.Procedure<? super T> procedure)
com.gs.collections.api.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 com.gs.collections.api.collection.MutableCollection<T>tap in interface com.gs.collections.api.RichIterable<T>tap in interface com.gs.collections.api.set.MutableSet<T>tap in interface com.gs.collections.api.set.MutableSetIterable<T>RichIterable.each(Procedure),
InternalIterable.forEach(Procedure)public void each(com.gs.collections.api.block.procedure.Procedure<? super T> procedure)
com.gs.collections.api.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 com.gs.collections.api.RichIterable<T>InternalIterable.forEach(Procedure),
Iterable#forEach(java.util.function.Consumer)public <P> void forEachWith(com.gs.collections.api.block.procedure.Procedure2<? super T,? super P> procedure, P parameter)
com.gs.collections.api.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 com.gs.collections.api.InternalIterable<T>forEachWith in class AbstractRichIterable<T>public void forEachWithIndex(com.gs.collections.api.block.procedure.primitive.ObjectIntProcedure<? super T> objectIntProcedure)
com.gs.collections.api.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 com.gs.collections.api.InternalIterable<T>forEachWithIndex in class AbstractRichIterable<T>public UnifiedSetWithHashingStrategy<T> newEmpty()
com.gs.collections.api.collection.MutableCollectionpublic T getFirst()
com.gs.collections.api.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 com.gs.collections.api.RichIterable<T>public T getLast()
com.gs.collections.api.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 com.gs.collections.api.RichIterable<T>public UnifiedSetWithHashingStrategy<T> select(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
com.gs.collections.api.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 com.gs.collections.api.collection.MutableCollection<T>select in interface com.gs.collections.api.RichIterable<T>select in interface com.gs.collections.api.set.MutableSet<T>select in interface com.gs.collections.api.set.MutableSetIterable<T>select in interface com.gs.collections.api.set.SetIterable<T>select in interface com.gs.collections.api.set.UnsortedSetIterable<T>public <P> UnifiedSetWithHashingStrategy<T> selectWith(com.gs.collections.api.block.predicate.Predicate2<? super T,? super P> predicate, P parameter)
com.gs.collections.api.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 com.gs.collections.api.collection.MutableCollection<T>selectWith in interface com.gs.collections.api.RichIterable<T>selectWith in interface com.gs.collections.api.set.MutableSet<T>selectWith in interface com.gs.collections.api.set.MutableSetIterable<T>selectWith in interface com.gs.collections.api.set.SetIterable<T>selectWith in interface com.gs.collections.api.set.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 UnifiedSetWithHashingStrategy<T> reject(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
com.gs.collections.api.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 com.gs.collections.api.collection.MutableCollection<T>reject in interface com.gs.collections.api.RichIterable<T>reject in interface com.gs.collections.api.set.MutableSet<T>reject in interface com.gs.collections.api.set.MutableSetIterable<T>reject in interface com.gs.collections.api.set.SetIterable<T>reject in interface com.gs.collections.api.set.UnsortedSetIterable<T>predicate - a Predicate to use as the reject criteriaPredicate.accept(Object) method to evaluate to falsepublic <P> UnifiedSetWithHashingStrategy<T> rejectWith(com.gs.collections.api.block.predicate.Predicate2<? super T,? super P> predicate, P parameter)
com.gs.collections.api.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 com.gs.collections.api.collection.MutableCollection<T>rejectWith in interface com.gs.collections.api.RichIterable<T>rejectWith in interface com.gs.collections.api.set.MutableSet<T>rejectWith in interface com.gs.collections.api.set.MutableSetIterable<T>rejectWith in interface com.gs.collections.api.set.SetIterable<T>rejectWith in interface com.gs.collections.api.set.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> com.gs.collections.api.tuple.Twin<com.gs.collections.api.list.MutableList<T>> selectAndRejectWith(com.gs.collections.api.block.predicate.Predicate2<? super T,? super P> predicate, P parameter)
com.gs.collections.api.collection.MutableCollection
e.g. return lastNames.selectAndRejectWith(PredicatesLite.lessThan(), "Mason");
selectAndRejectWith in interface com.gs.collections.api.collection.MutableCollection<T>public com.gs.collections.api.partition.set.PartitionMutableSet<T> partition(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
com.gs.collections.api.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 com.gs.collections.api.collection.MutableCollection<T>partition in interface com.gs.collections.api.RichIterable<T>partition in interface com.gs.collections.api.set.MutableSet<T>partition in interface com.gs.collections.api.set.MutableSetIterable<T>partition in interface com.gs.collections.api.set.SetIterable<T>public <P> com.gs.collections.api.partition.set.PartitionMutableSet<T> partitionWith(com.gs.collections.api.block.predicate.Predicate2<? super T,? super P> predicate, P parameter)
com.gs.collections.api.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 com.gs.collections.api.collection.MutableCollection<T>partitionWith in interface com.gs.collections.api.RichIterable<T>partitionWith in interface com.gs.collections.api.set.MutableSet<T>partitionWith in interface com.gs.collections.api.set.MutableSetIterable<T>partitionWith in interface com.gs.collections.api.set.SetIterable<T>public <S> UnifiedSetWithHashingStrategy<S> selectInstancesOf(java.lang.Class<S> clazz)
com.gs.collections.api.RichIterableclazz.selectInstancesOf in interface com.gs.collections.api.collection.MutableCollection<T>selectInstancesOf in interface com.gs.collections.api.RichIterable<T>selectInstancesOf in interface com.gs.collections.api.set.MutableSet<T>selectInstancesOf in interface com.gs.collections.api.set.MutableSetIterable<T>selectInstancesOf in interface com.gs.collections.api.set.SetIterable<T>selectInstancesOf in interface com.gs.collections.api.set.UnsortedSetIterable<T>protected T detect(com.gs.collections.api.block.predicate.Predicate<? super T> predicate, int start, int end)
detect in class AbstractUnifiedSet<T>protected boolean shortCircuit(com.gs.collections.api.block.predicate.Predicate<? super T> predicate, boolean expected, boolean onShortCircuit, boolean atEnd, int start, int end)
shortCircuit in class AbstractUnifiedSet<T>protected <P> boolean shortCircuitWith(com.gs.collections.api.block.predicate.Predicate2<? super T,? super P> predicate2, P parameter, boolean expected, boolean onShortCircuit, boolean atEnd)
shortCircuitWith in class AbstractUnifiedSet<T>@Deprecated public com.gs.collections.api.LazyIterable<T> lazySelect(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
@Deprecated public com.gs.collections.api.LazyIterable<T> lazyReject(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
@Deprecated public <V> com.gs.collections.api.LazyIterable<V> lazyCollect(com.gs.collections.api.block.function.Function<? super T,? extends V> function)
AbstractRichIterable.asLazy().AbstractUnifiedSet.collect(Function) instead.public com.gs.collections.api.set.ImmutableSet<T> toImmutable()
com.gs.collections.api.set.MutableSetThe returned set will be Serializable if this set is Serializable.
toImmutable in interface com.gs.collections.api.collection.MutableCollection<T>toImmutable in interface com.gs.collections.api.set.MutableSet<T>toImmutable in interface com.gs.collections.api.set.SetIterable<T>toImmutable in interface com.gs.collections.api.set.UnsortedSetIterable<T>public UnifiedSetWithHashingStrategy<T> with(T element)
com.gs.collections.api.collection.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.public UnifiedSetWithHashingStrategy<T> with(T element1, T element2)
public UnifiedSetWithHashingStrategy<T> with(T element1, T element2, T element3)
public UnifiedSetWithHashingStrategy<T> with(T... elements)
public UnifiedSetWithHashingStrategy<T> withAll(java.lang.Iterable<? extends T> iterable)
com.gs.collections.api.collection.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.public UnifiedSetWithHashingStrategy<T> without(T element)
com.gs.collections.api.collection.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.public UnifiedSetWithHashingStrategy<T> withoutAll(java.lang.Iterable<? extends T> elements)
com.gs.collections.api.collection.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.public boolean addAllIterable(java.lang.Iterable<? extends T> iterable)
addAllIterable in interface com.gs.collections.api.collection.MutableCollection<T>Collection.addAll(Collection)protected boolean copySet(UnifiedSetWithHashingStrategy<?> unifiedset)
public boolean remove(java.lang.Object key)
public int size()
com.gs.collections.api.RichIterablepublic boolean equals(java.lang.Object object)
com.gs.collections.api.set.SetIterableSet.equals(Object).public int hashCode()
com.gs.collections.api.set.SetIterableSet.hashCode().public void readExternal(java.io.ObjectInput in)
throws java.io.IOException,
java.lang.ClassNotFoundException
readExternal in interface java.io.Externalizablejava.io.IOExceptionjava.lang.ClassNotFoundExceptionpublic void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException
writeExternal in interface java.io.Externalizablejava.io.IOExceptionpublic boolean retainAllIterable(java.lang.Iterable<?> iterable)
retainAllIterable in interface com.gs.collections.api.collection.MutableCollection<T>Collection.retainAll(Collection)public UnifiedSetWithHashingStrategy<T> clone()
clone in interface com.gs.collections.api.set.MutableSet<T>clone in class AbstractUnifiedSet<T>public java.lang.Object[] toArray()
com.gs.collections.api.RichIterablepublic <T> T[] toArray(T[] array)
com.gs.collections.api.RichIterablepublic java.util.Iterator<T> iterator()
public <V> UnifiedSetWithHashingStrategyMultimap<V,T> groupBy(com.gs.collections.api.block.function.Function<? super T,? extends V> function)
com.gs.collections.api.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 value(Person person)
{
return person.getLastName();
}
});
groupBy in interface com.gs.collections.api.collection.MutableCollection<T>groupBy in interface com.gs.collections.api.RichIterable<T>groupBy in interface com.gs.collections.api.set.MutableSet<T>groupBy in interface com.gs.collections.api.set.MutableSetIterable<T>groupBy in interface com.gs.collections.api.set.UnsortedSetIterable<T>public <V> UnifiedSetMultimap<V,T> groupByEach(com.gs.collections.api.block.function.Function<? super T,? extends java.lang.Iterable<V>> function)
com.gs.collections.api.RichIterableRichIterable.groupBy(Function), except the result of evaluating function will return a collection of keys
for each value.groupByEach in interface com.gs.collections.api.collection.MutableCollection<T>groupByEach in interface com.gs.collections.api.RichIterable<T>groupByEach in interface com.gs.collections.api.set.MutableSet<T>groupByEach in interface com.gs.collections.api.set.MutableSetIterable<T>groupByEach in interface com.gs.collections.api.set.UnsortedSetIterable<T>groupByEach in class AbstractUnifiedSet<T>public T get(T key)
com.gs.collections.api.set.Poolkey.get in interface com.gs.collections.api.set.Pool<T>key - the value to look forpublic T put(T key)
com.gs.collections.api.set.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.put in interface com.gs.collections.api.set.Pool<T>key - the value to add if not in the poolpublic T removeFromPool(T key)
com.gs.collections.api.set.Poolkey and removes it.removeFromPool in interface com.gs.collections.api.set.Pool<T>key - object to removepublic com.gs.collections.api.set.ParallelUnsortedSetIterable<T> asParallel(java.util.concurrent.ExecutorService executorService, int batchSize)
com.gs.collections.api.set.SetIterable