@Immutable public abstract class AbstractLazyIterable<T> extends AbstractRichIterable<T> implements com.gs.collections.api.LazyIterable<T>
| Constructor and Description |
|---|
AbstractLazyIterable() |
| Modifier and Type | Method and Description |
|---|---|
<K,V> com.gs.collections.api.map.MapIterable<K,V> |
aggregateBy(com.gs.collections.api.block.function.Function<? super T,? extends K> groupBy,
com.gs.collections.api.block.function.Function0<? extends V> zeroValueFactory,
com.gs.collections.api.block.function.Function2<? super V,? super T,? extends V> nonMutatingAggregator)
Applies an aggregate function over the iterable grouping results into a map based on the specific groupBy function.
|
<K,V> com.gs.collections.api.map.MapIterable<K,V> |
aggregateInPlaceBy(com.gs.collections.api.block.function.Function<? super T,? extends K> groupBy,
com.gs.collections.api.block.function.Function0<? extends V> zeroValueFactory,
com.gs.collections.api.block.procedure.Procedure2<? super V,? super T> mutatingAggregator)
Applies an aggregate procedure over the iterable grouping results into a Map based on the specific groupBy function.
|
com.gs.collections.api.LazyIterable<T> |
asLazy()
Returns a lazy (deferred) iterable, most likely implemented by calling LazyIterate.adapt(this).
|
com.gs.collections.api.LazyIterable<com.gs.collections.api.RichIterable<T>> |
chunk(int size)
Creates a deferred chunking iterable.
|
<V> com.gs.collections.api.LazyIterable<V> |
collect(com.gs.collections.api.block.function.Function<? super T,? extends V> function)
Creates a deferred iterable for collecting elements from the current iterable.
|
com.gs.collections.api.LazyBooleanIterable |
collectBoolean(com.gs.collections.api.block.function.primitive.BooleanFunction<? super T> booleanFunction)
Returns a lazy BooleanIterable which will transform the underlying iterable data to boolean values based on the booleanFunction.
|
com.gs.collections.api.LazyByteIterable |
collectByte(com.gs.collections.api.block.function.primitive.ByteFunction<? super T> byteFunction)
Returns a lazy ByteIterable which will transform the underlying iterable data to byte values based on the byteFunction.
|
com.gs.collections.api.LazyCharIterable |
collectChar(com.gs.collections.api.block.function.primitive.CharFunction<? super T> charFunction)
Returns a lazy CharIterable which will transform the underlying iterable data to char values based on the charFunction.
|
com.gs.collections.api.LazyDoubleIterable |
collectDouble(com.gs.collections.api.block.function.primitive.DoubleFunction<? super T> doubleFunction)
Returns a lazy DoubleIterable which will transform the underlying iterable data to double values based on the doubleFunction.
|
com.gs.collections.api.LazyFloatIterable |
collectFloat(com.gs.collections.api.block.function.primitive.FloatFunction<? super T> floatFunction)
Returns a lazy FloatIterable which will transform the underlying iterable data to float values based on the floatFunction.
|
<V> com.gs.collections.api.LazyIterable<V> |
collectIf(com.gs.collections.api.block.predicate.Predicate<? super T> predicate,
com.gs.collections.api.block.function.Function<? super T,? extends V> function)
Creates a deferred iterable for selecting and collecting elements from the current iterable.
|
com.gs.collections.api.LazyIntIterable |
collectInt(com.gs.collections.api.block.function.primitive.IntFunction<? super T> intFunction)
Returns a lazy IntIterable which will transform the underlying iterable data to int values based on the intFunction.
|
com.gs.collections.api.LazyLongIterable |
collectLong(com.gs.collections.api.block.function.primitive.LongFunction<? super T> longFunction)
Returns a lazy LongIterable which will transform the underlying iterable data to long values based on the longFunction.
|
com.gs.collections.api.LazyShortIterable |
collectShort(com.gs.collections.api.block.function.primitive.ShortFunction<? super T> shortFunction)
Returns a lazy ShortIterable which will transform the underlying iterable data to short values based on the shortFunction.
|
<P,V> com.gs.collections.api.LazyIterable<V> |
collectWith(com.gs.collections.api.block.function.Function2<? super T,? super P,? extends V> function,
P parameter)
Same as
RichIterable.collect(Function) with a Function2 and specified parameter which is passed to the block. |
com.gs.collections.api.LazyIterable<T> |
concatenate(java.lang.Iterable<T> iterable)
Creates a deferred iterable that will join this iterable with the specified iterable.
|
com.gs.collections.api.LazyIterable<T> |
distinct()
Creates a deferred distinct iterable to get distinct elements from the current iterable.
|
com.gs.collections.api.LazyIterable<T> |
drop(int count)
Creates a deferred drop iterable for the current iterable using the specified count as the limit.
|
<V> com.gs.collections.api.LazyIterable<V> |
flatCollect(com.gs.collections.api.block.function.Function<? super T,? extends java.lang.Iterable<V>> function)
Creates a deferred flattening iterable for the current iterable.
|
T |
getFirst()
Returns the first element of an iterable.
|
T |
getLast()
Returns the last element of an iterable.
|
<V> com.gs.collections.api.multimap.Multimap<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> com.gs.collections.api.multimap.Multimap<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. |
<V> com.gs.collections.api.map.MapIterable<V,T> |
groupByUniqueKey(com.gs.collections.api.block.function.Function<? super T,? extends V> function)
For each element of the iterable, the function is evaluated and he results of these evaluations are collected
into a new map, where the transformed value is the key.
|
<R extends java.util.Collection<T>> |
into(R target)
Iterates over this iterable adding all elements into the target collection.
|
boolean |
isEmpty()
Returns true if this iterable has zero items.
|
com.gs.collections.api.partition.list.PartitionMutableList<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.list.PartitionMutableList<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.
|
com.gs.collections.api.LazyIterable<T> |
reject(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
Creates a deferred iterable for rejecting elements from the current iterable.
|
<P> com.gs.collections.api.LazyIterable<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. |
com.gs.collections.api.LazyIterable<T> |
select(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
Creates a deferred iterable for selecting elements from the current iterable.
|
<S> com.gs.collections.api.LazyIterable<S> |
selectInstancesOf(java.lang.Class<S> clazz)
Returns all elements of the source collection that are instances of the Class
clazz. |
<P> com.gs.collections.api.LazyIterable<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. |
int |
size()
Returns the number of items in this iterable.
|
com.gs.collections.api.LazyIterable<T> |
take(int count)
Creates a deferred take iterable for the current iterable using the specified count as the limit.
|
com.gs.collections.api.LazyIterable<T> |
tap(com.gs.collections.api.block.procedure.Procedure<? super T> procedure)
Creates a deferred tap iterable.
|
<E> E[] |
toArray(E[] 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.stack.MutableStack<T> |
toStack() |
<S> com.gs.collections.api.LazyIterable<com.gs.collections.api.tuple.Pair<T,S>> |
zip(java.lang.Iterable<S> that)
Creates a deferred zip iterable.
|
com.gs.collections.api.LazyIterable<com.gs.collections.api.tuple.Pair<T,java.lang.Integer>> |
zipWithIndex()
Creates a deferred zipWithIndex iterable.
|
allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, appendString, appendString, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, contains, containsAll, containsAllArguments, containsAllIterable, count, countWith, detect, detectIfNone, detectWith, detectWithIfNone, flatCollect, forEach, forEachWith, forEachWithIndex, groupBy, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, makeString, makeString, makeString, max, max, maxBy, min, min, minBy, noneSatisfy, noneSatisfyWith, notEmpty, reject, rejectWith, select, selectWith, sumByDouble, sumByFloat, sumByInt, sumByLong, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toArray, toBag, toList, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedSet, toSortedSet, toSortedSetBy, toString, zip, zipWithIndexclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitallSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, appendString, appendString, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, contains, containsAll, containsAllArguments, containsAllIterable, count, countWith, detect, detectIfNone, detectWith, detectWithIfNone, each, flatCollect, groupBy, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, makeString, makeString, makeString, max, max, maxBy, min, min, minBy, noneSatisfy, noneSatisfyWith, notEmpty, reject, rejectWith, select, selectWith, sumByDouble, sumByFloat, sumByInt, sumByLong, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toArray, toBag, toList, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedSet, toSortedSet, toSortedSetBy, toString, zip, zipWithIndexpublic com.gs.collections.api.LazyIterable<T> asLazy()
com.gs.collections.api.RichIterableasLazy in interface com.gs.collections.api.RichIterable<T>asLazy in class AbstractRichIterable<T>public <R extends java.util.Collection<T>> R into(R target)
com.gs.collections.api.LazyIterableinto in interface com.gs.collections.api.LazyIterable<T>public <E> E[] toArray(E[] array)
com.gs.collections.api.RichIterabletoArray in interface com.gs.collections.api.RichIterable<T>toArray in class AbstractRichIterable<T>Collection.toArray(Object[])public int size()
com.gs.collections.api.RichIterablesize in interface com.gs.collections.api.RichIterable<T>public boolean isEmpty()
com.gs.collections.api.RichIterableisEmpty in interface com.gs.collections.api.RichIterable<T>isEmpty in class AbstractRichIterable<T>public 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.
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 com.gs.collections.api.LazyIterable<T> select(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
com.gs.collections.api.LazyIterablepublic <P> com.gs.collections.api.LazyIterable<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.LazyIterable<T>selectWith in interface com.gs.collections.api.RichIterable<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 com.gs.collections.api.LazyIterable<T> reject(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
com.gs.collections.api.LazyIterablereject in interface com.gs.collections.api.LazyIterable<T>reject in interface com.gs.collections.api.RichIterable<T>predicate - a Predicate to use as the reject criteriaPredicate.accept(Object) method to evaluate to falsepublic <P> com.gs.collections.api.LazyIterable<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.LazyIterable<T>rejectWith in interface com.gs.collections.api.RichIterable<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 com.gs.collections.api.partition.list.PartitionMutableList<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.RichIterable<T>public <P> com.gs.collections.api.partition.list.PartitionMutableList<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.RichIterable<T>public <S> com.gs.collections.api.LazyIterable<S> selectInstancesOf(java.lang.Class<S> clazz)
com.gs.collections.api.RichIterableclazz.public <V> com.gs.collections.api.LazyIterable<V> collect(com.gs.collections.api.block.function.Function<? super T,? extends V> function)
com.gs.collections.api.LazyIterablepublic com.gs.collections.api.LazyBooleanIterable collectBoolean(com.gs.collections.api.block.function.primitive.BooleanFunction<? super T> booleanFunction)
com.gs.collections.api.LazyIterablepublic com.gs.collections.api.LazyByteIterable collectByte(com.gs.collections.api.block.function.primitive.ByteFunction<? super T> byteFunction)
com.gs.collections.api.LazyIterablepublic com.gs.collections.api.LazyCharIterable collectChar(com.gs.collections.api.block.function.primitive.CharFunction<? super T> charFunction)
com.gs.collections.api.LazyIterablepublic com.gs.collections.api.LazyDoubleIterable collectDouble(com.gs.collections.api.block.function.primitive.DoubleFunction<? super T> doubleFunction)
com.gs.collections.api.LazyIterablepublic com.gs.collections.api.LazyFloatIterable collectFloat(com.gs.collections.api.block.function.primitive.FloatFunction<? super T> floatFunction)
com.gs.collections.api.LazyIterablepublic com.gs.collections.api.LazyIntIterable collectInt(com.gs.collections.api.block.function.primitive.IntFunction<? super T> intFunction)
com.gs.collections.api.LazyIterablepublic com.gs.collections.api.LazyLongIterable collectLong(com.gs.collections.api.block.function.primitive.LongFunction<? super T> longFunction)
com.gs.collections.api.LazyIterablepublic com.gs.collections.api.LazyShortIterable collectShort(com.gs.collections.api.block.function.primitive.ShortFunction<? super T> shortFunction)
com.gs.collections.api.LazyIterablepublic <P,V> com.gs.collections.api.LazyIterable<V> collectWith(com.gs.collections.api.block.function.Function2<? super T,? super P,? extends V> function, P parameter)
com.gs.collections.api.RichIterableRichIterable.collect(Function) with a Function2 and specified parameter which is passed to the block.
Example using a Java 8 lambda expression:
RichIterable<Integer> integers =
Lists.mutable.with(1, 2, 3).collectWith((each, parameter) -> each + parameter, Integer.valueOf(1));
Example using an anonymous inner class:
Function2<Integer, Integer, Integer> addParameterFunction =
new Function2<Integer, Integer, Integer>()
{
public Integer value(Integer each, Integer parameter)
{
return each + parameter;
}
};
RichIterable<Integer> integers =
Lists.mutable.with(1, 2, 3).collectWith(addParameterFunction, Integer.valueOf(1));
collectWith in interface com.gs.collections.api.LazyIterable<T>collectWith in interface com.gs.collections.api.RichIterable<T>function - A Function2 to use as the collect transformation functionparameter - A parameter to pass in for evaluation of the second argument P in functionRichIterable that contains the transformed elements returned by Function2.value(Object, Object)RichIterable.collect(Function)public <V> com.gs.collections.api.LazyIterable<V> flatCollect(com.gs.collections.api.block.function.Function<? super T,? extends java.lang.Iterable<V>> function)
com.gs.collections.api.LazyIterablepublic com.gs.collections.api.LazyIterable<T> concatenate(java.lang.Iterable<T> iterable)
com.gs.collections.api.LazyIterableconcatenate in interface com.gs.collections.api.LazyIterable<T>public <V> com.gs.collections.api.LazyIterable<V> collectIf(com.gs.collections.api.block.predicate.Predicate<? super T> predicate, com.gs.collections.api.block.function.Function<? super T,? extends V> function)
com.gs.collections.api.LazyIterablepublic com.gs.collections.api.LazyIterable<T> take(int count)
com.gs.collections.api.LazyIterabletake in interface com.gs.collections.api.LazyIterable<T>public com.gs.collections.api.LazyIterable<T> drop(int count)
com.gs.collections.api.LazyIterabledrop in interface com.gs.collections.api.LazyIterable<T>public com.gs.collections.api.LazyIterable<T> distinct()
com.gs.collections.api.LazyIterabledistinct in interface com.gs.collections.api.LazyIterable<T>public com.gs.collections.api.stack.MutableStack<T> toStack()
public <V> com.gs.collections.api.multimap.Multimap<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.RichIterable<T>public <V> com.gs.collections.api.multimap.Multimap<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.RichIterable<T>public <V> com.gs.collections.api.map.MapIterable<V,T> groupByUniqueKey(com.gs.collections.api.block.function.Function<? super T,? extends V> function)
com.gs.collections.api.RichIterablegroupByUniqueKey in interface com.gs.collections.api.RichIterable<T>RichIterable.groupBy(Function)public <S> com.gs.collections.api.LazyIterable<com.gs.collections.api.tuple.Pair<T,S>> zip(java.lang.Iterable<S> that)
com.gs.collections.api.LazyIterablezip in interface com.gs.collections.api.LazyIterable<T>zip in interface com.gs.collections.api.RichIterable<T>S - the type of the second half of the returned pairsthat - The RichIterable providing the second half of each result pairRichIterable containing pairs consisting of corresponding elements of this RichIterable and that. The length of the returned RichIterable is the minimum of the lengths of
this RichIterable and that.public com.gs.collections.api.LazyIterable<com.gs.collections.api.tuple.Pair<T,java.lang.Integer>> zipWithIndex()
com.gs.collections.api.LazyIterablezipWithIndex in interface com.gs.collections.api.LazyIterable<T>zipWithIndex in interface com.gs.collections.api.RichIterable<T>RichIterable containing pairs consisting of all elements of this RichIterable
paired with their index. Indices start at 0.RichIterable.zip(Iterable)public com.gs.collections.api.LazyIterable<com.gs.collections.api.RichIterable<T>> chunk(int size)
com.gs.collections.api.LazyIterablechunk in interface com.gs.collections.api.LazyIterable<T>chunk in interface com.gs.collections.api.RichIterable<T>size - the number of elements per chunkRichIterable containing RichIterables of size size, except the last will be
truncated if the elements don't divide evenly.public com.gs.collections.api.LazyIterable<T> tap(com.gs.collections.api.block.procedure.Procedure<? super T> procedure)
com.gs.collections.api.LazyIterablepublic <K,V> com.gs.collections.api.map.MapIterable<K,V> aggregateInPlaceBy(com.gs.collections.api.block.function.Function<? super T,? extends K> groupBy, com.gs.collections.api.block.function.Function0<? extends V> zeroValueFactory, com.gs.collections.api.block.procedure.Procedure2<? super V,? super T> mutatingAggregator)
com.gs.collections.api.RichIterableaggregateInPlaceBy in interface com.gs.collections.api.RichIterable<T>public <K,V> com.gs.collections.api.map.MapIterable<K,V> aggregateBy(com.gs.collections.api.block.function.Function<? super T,? extends K> groupBy, com.gs.collections.api.block.function.Function0<? extends V> zeroValueFactory, com.gs.collections.api.block.function.Function2<? super V,? super T,? extends V> nonMutatingAggregator)
com.gs.collections.api.RichIterableaggregateBy in interface com.gs.collections.api.RichIterable<T>