@Immutable public class LazyIterableAdapter<T> extends AbstractLazyIterable<T>
| Constructor and Description |
|---|
LazyIterableAdapter(java.lang.Iterable<T> newAdapted) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
allSatisfy(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
Returns true if the predicate evaluates to true for every element of the iterable or if the iterable is empty.
|
<P> boolean |
allSatisfyWith(com.gs.collections.api.block.predicate.Predicate2<? super T,? super P> predicate,
P parameter)
Returns true if the predicate evaluates to true for every element of the collection, or returns false.
|
boolean |
anySatisfy(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
Returns true if the predicate evaluates to true for any element of the iterable.
|
<P> boolean |
anySatisfyWith(com.gs.collections.api.block.predicate.Predicate2<? super T,? super P> predicate,
P parameter)
Returns true if the predicate evaluates to true for any element of the collection, or return false.
|
<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.
|
<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.
|
T |
detect(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
Returns the first element of the iterable for which the predicate evaluates to true or null in the case where no
element returns true.
|
<P> T |
detectWith(com.gs.collections.api.block.predicate.Predicate2<? super T,? super P> predicate,
P parameter)
Returns the first element that evaluates to true for the specified predicate2 and parameter, or null if none
evaluate to true.
|
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.
|
void |
each(com.gs.collections.api.block.procedure.Procedure<? super T> procedure)
The procedure is executed for each element in the iterable.
|
<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.
|
<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 |
getFirst()
Returns the first element of an iterable.
|
T |
getLast()
Returns the last element of an iterable.
|
<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.
|
java.util.Iterator<T> |
iterator() |
boolean |
noneSatisfy(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
Returns true if the predicate evaluates to false for every element of the iterable or if the iterable is empty.
|
<P> boolean |
noneSatisfyWith(com.gs.collections.api.block.predicate.Predicate2<? super T,? super P> predicate,
P parameter)
Returns true if the predicate evaluates to false for every element of the collection, or return false.
|
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.
|
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.
|
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.
|
java.lang.Object[] |
toArray()
Converts this iterable to an array.
|
aggregateBy, aggregateInPlaceBy, asLazy, chunk, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectInt, collectLong, collectShort, collectWith, concatenate, groupBy, groupByEach, groupByUniqueKey, partition, partitionWith, rejectWith, selectInstancesOf, selectWith, tap, toArray, toStack, zip, zipWithIndexappendString, appendString, appendString, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, contains, containsAll, containsAllArguments, containsAllIterable, count, countWith, detectIfNone, detectWithIfNone, flatCollect, forEach, groupBy, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, 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, zipWithIndexclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitappendString, appendString, appendString, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, contains, containsAll, containsAllArguments, containsAllIterable, count, countWith, detectIfNone, detectWithIfNone, flatCollect, groupBy, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, 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, zipWithIndexpublic LazyIterableAdapter(java.lang.Iterable<T> newAdapted)
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).InternalIterable.forEach(Procedure),
Iterable#forEach(java.util.function.Consumer)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 <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 java.util.Iterator<T> iterator()
public <R extends java.util.Collection<T>> R into(R target)
com.gs.collections.api.LazyIterableinto in interface com.gs.collections.api.LazyIterable<T>into in class AbstractLazyIterable<T>public com.gs.collections.api.LazyIterable<T> select(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
com.gs.collections.api.LazyIterableselect in interface com.gs.collections.api.LazyIterable<T>select in interface com.gs.collections.api.RichIterable<T>select in class AbstractLazyIterable<T>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>reject in class AbstractLazyIterable<T>predicate - a Predicate to use as the reject criteriaPredicate.accept(Object) method to evaluate to falsepublic <V> com.gs.collections.api.LazyIterable<V> collect(com.gs.collections.api.block.function.Function<? super T,? extends V> function)
com.gs.collections.api.LazyIterablecollect in interface com.gs.collections.api.LazyIterable<T>collect in interface com.gs.collections.api.RichIterable<T>collect in class AbstractLazyIterable<T>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.LazyIterableflatCollect in interface com.gs.collections.api.LazyIterable<T>flatCollect in interface com.gs.collections.api.RichIterable<T>flatCollect in class AbstractLazyIterable<T>function - The Function to applyfunctionpublic <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.LazyIterablecollectIf in interface com.gs.collections.api.LazyIterable<T>collectIf in interface com.gs.collections.api.RichIterable<T>collectIf in class AbstractLazyIterable<T>public com.gs.collections.api.LazyIterable<T> take(int count)
com.gs.collections.api.LazyIterabletake in interface com.gs.collections.api.LazyIterable<T>take in class AbstractLazyIterable<T>public com.gs.collections.api.LazyIterable<T> drop(int count)
com.gs.collections.api.LazyIterabledrop in interface com.gs.collections.api.LazyIterable<T>drop in class AbstractLazyIterable<T>public com.gs.collections.api.LazyIterable<T> distinct()
com.gs.collections.api.LazyIterabledistinct in interface com.gs.collections.api.LazyIterable<T>distinct in class AbstractLazyIterable<T>public java.lang.Object[] toArray()
com.gs.collections.api.RichIterabletoArray in interface com.gs.collections.api.RichIterable<T>toArray in class AbstractRichIterable<T>Collection.toArray()public int size()
com.gs.collections.api.RichIterablesize in interface com.gs.collections.api.RichIterable<T>size in class AbstractLazyIterable<T>public boolean isEmpty()
com.gs.collections.api.RichIterableisEmpty in interface com.gs.collections.api.RichIterable<T>isEmpty in class AbstractLazyIterable<T>public boolean anySatisfy(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
com.gs.collections.api.RichIterableanySatisfy in interface com.gs.collections.api.RichIterable<T>anySatisfy in class AbstractRichIterable<T>public boolean allSatisfy(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
com.gs.collections.api.RichIterableallSatisfy in interface com.gs.collections.api.RichIterable<T>allSatisfy in class AbstractRichIterable<T>public boolean noneSatisfy(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
com.gs.collections.api.RichIterablenoneSatisfy in interface com.gs.collections.api.RichIterable<T>noneSatisfy in class AbstractRichIterable<T>public <P> boolean anySatisfyWith(com.gs.collections.api.block.predicate.Predicate2<? super T,? super P> predicate, P parameter)
com.gs.collections.api.RichIterableanySatisfyWith in interface com.gs.collections.api.RichIterable<T>anySatisfyWith in class AbstractRichIterable<T>public <P> boolean allSatisfyWith(com.gs.collections.api.block.predicate.Predicate2<? super T,? super P> predicate, P parameter)
com.gs.collections.api.RichIterableallSatisfyWith in interface com.gs.collections.api.RichIterable<T>allSatisfyWith in class AbstractRichIterable<T>public <P> boolean noneSatisfyWith(com.gs.collections.api.block.predicate.Predicate2<? super T,? super P> predicate, P parameter)
com.gs.collections.api.RichIterablenoneSatisfyWith in interface com.gs.collections.api.RichIterable<T>noneSatisfyWith 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.
getFirst in interface com.gs.collections.api.LazyIterable<T>getFirst in interface com.gs.collections.api.RichIterable<T>getFirst in class AbstractLazyIterable<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>getLast in class AbstractLazyIterable<T>public T detect(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
com.gs.collections.api.RichIterableExample using a Java 8 lambda expression:
Person person =
people.detect(person -> person.getFirstName().equals("John") && person.getLastName().equals("Smith"));
Example using an anonymous inner class:
Person person =
people.detect(new Predicate<Person>()
{
public boolean value(Person person)
{
return person.getFirstName().equals("John") && person.getLastName().equals("Smith");
}
});
detect in interface com.gs.collections.api.RichIterable<T>detect in class AbstractRichIterable<T>public <P> T detectWith(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:
Person person =
people.detectWith((person, fullName) -> person.getFullName().equals(fullName), "John Smith");
Example using an anonymous inner class:
Person person =
people.detectWith(new Predicate2<Person, String>()
{
public boolean value(Person person, String fullName)
{
return person.getFullName().equals(fullName);
}
}, "John Smith");
detectWith in interface com.gs.collections.api.RichIterable<T>detectWith in class AbstractRichIterable<T>