public final class CompositeFastList<E> extends AbstractMutableList<E> implements BatchIterable<E>, Serializable
Note: mutation operations (e.g. add and remove, sorting) will change the underlying lists - so be sure to only use a composite list where it will be the only reference to the sublists (for example, a composite list which contains multiple query results is OK as long as it is the only thing that references the lists)
Constructor and Description |
---|
CompositeFastList() |
Modifier and Type | Method and Description |
---|---|
boolean |
add(E object) |
void |
add(int index,
E element) |
boolean |
addAll(Collection<? extends E> collection) |
boolean |
addAll(int index,
Collection<? extends E> collection) |
void |
addComposited(Collection<? extends E> collection) |
boolean |
allSatisfy(Predicate<? super E> predicate)
Returns true if the predicate evaluates to true for every element of the iterable or if the iterable is empty.
|
<P> boolean |
allSatisfyWith(Predicate2<? super E,? super P> predicate,
P parameter)
Returns true if the predicate evaluates to true for every element of the collection, or returns false.
|
boolean |
anySatisfy(Predicate<? super E> predicate)
Returns true if the predicate evaluates to true for any element of the iterable.
|
<P> boolean |
anySatisfyWith(Predicate2<? super E,? super P> predicate,
P parameter)
Returns true if the predicate evaluates to true for any element of the collection, or return false.
|
ParallelListIterable<E> |
asParallel(ExecutorService executorService,
int batchSize)
Returns a parallel iterable of this ListIterable.
|
void |
batchForEach(Procedure<? super E> procedure,
int sectionIndex,
int sectionCount) |
void |
clear() |
MutableList<E> |
clone() |
<V,R extends Collection<V>> |
collect(Function<? super E,? extends V> function,
R target)
Same as
RichIterable.collect(Function) , except that the results are gathered into the specified target
collection. |
<P,A,R extends Collection<A>> |
collectWith(Function2<? super E,? super P,? extends A> function,
P parameter,
R target)
Same as collectWith but with a targetCollection parameter to gather the results.
|
boolean |
contains(Object object)
Returns true if the iterable has an element which responds true to element.equals(object).
|
boolean |
containsAll(Collection<?> collection)
Returns true if all elements in source are contained in this collection.
|
int |
count(Predicate<? super E> predicate)
Return the total number of elements that answer true to the specified predicate.
|
<P> int |
countWith(Predicate2<? super E,? super P> predicate,
P parameter)
Returns the total number of elements that evaluate to true for the specified predicate.
|
void |
each(Procedure<? super E> procedure)
The procedure is executed for each element in the iterable.
|
<P> void |
forEachWith(Procedure2<? super E,? super P> procedure2,
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 E> objectIntProcedure)
Iterates over the iterable passing each element and the current relative int index to the specified instance of
ObjectIntProcedure.
|
E |
get(int index)
Returns the item at the specified position in this list iterable.
|
int |
getBatchCount(int batchSize) |
int |
indexOf(Object o)
Returns the index of the first occurrence of the specified item
in this iterable, or -1 if this iterable does not contain the item.
|
double |
injectInto(double injectedValue,
DoubleObjectToDoubleFunction<? super E> function)
Returns the final double result of evaluating function using each element of the iterable and the previous evaluation
result as the parameters.
|
float |
injectInto(float injectedValue,
FloatObjectToFloatFunction<? super E> function)
Returns the final float result of evaluating function using each element of the iterable and the previous evaluation
result as the parameters.
|
int |
injectInto(int injectedValue,
IntObjectToIntFunction<? super E> function)
Returns the final int result of evaluating function using each element of the iterable and the previous evaluation
result as the parameters.
|
<IV> IV |
injectInto(IV injectedValue,
Function2<? super IV,? super E,? extends IV> function)
Returns the final result of evaluating function using each element of the iterable and the previous evaluation
result as the parameters.
|
long |
injectInto(long injectedValue,
LongObjectToLongFunction<? super E> function)
Returns the final long result of evaluating function using each element of the iterable and the previous evaluation
result as the parameters.
|
boolean |
isEmpty()
Returns true if this iterable has zero items.
|
Iterator<E> |
iterator() |
int |
lastIndexOf(Object o)
Returns the index of the last occurrence of the specified item
in this list, or -1 if this list does not contain the item.
|
ListIterator<E> |
listIterator()
a list iterator is a problem for a composite list as going back in the order of the list is an issue,
as are the other methods like set() and add() (and especially, remove).
|
ListIterator<E> |
listIterator(int index)
a list iterator is a problem for a composite list as going back in the order of the list is an issue,
as are the other methods like set() and add() (and especially, remove).
|
boolean |
noneSatisfy(Predicate<? super E> predicate)
Returns true if the predicate evaluates to false for every element of the iterable or if the iterable is empty.
|
<P> boolean |
noneSatisfyWith(Predicate2<? super E,? super P> predicate,
P parameter)
Returns true if the predicate evaluates to false for every element of the collection, or return false.
|
<R extends Collection<E>> |
reject(Predicate<? super E> predicate,
R target)
Same as the reject method with one parameter but uses the specified target collection for the results.
|
<P,R extends Collection<E>> |
rejectWith(Predicate2<? super E,? super P> predicate,
P parameter,
R target)
Similar to
RichIterable.reject(Predicate, Collection) , except with an evaluation parameter for the second generic argument in Predicate2 . |
E |
remove(int index) |
boolean |
remove(Object object) |
boolean |
removeAll(Collection<?> collection) |
void |
resetSize() |
boolean |
retainAll(Collection<?> collection) |
void |
reverseForEach(Procedure<? super E> procedure)
Evaluates the procedure for each element of the list iterating in reverse order.
|
CompositeFastList<E> |
reverseThis()
Mutates the current list by reversing its order and returns the current list as a result
|
<R extends Collection<E>> |
select(Predicate<? super E> predicate,
R target)
Same as the select method with one parameter but uses the specified target collection for the results.
|
<P,R extends Collection<E>> |
selectWith(Predicate2<? super E,? super P> predicate,
P parameter,
R target)
Similar to
RichIterable.select(Predicate, Collection) , except with an evaluation parameter for the second generic argument in Predicate2 . |
E |
set(int index,
E element) |
int |
size()
Returns the number of items in this iterable.
|
Object[] |
toArray()
Converts this iterable to an array.
|
Object[] |
toArray(Object[] array)
Converts this iterable to an array using the specified target array, assuming the target array is as long
or longer than the iterable.
|
appendString, appendString, asReversed, asSynchronized, asUnmodifiable, binarySearch, binarySearch, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectIf, collectInt, collectLong, collectShort, collectWith, corresponds, detect, detectIfNone, detectIndex, detectLastIndex, detectWith, detectWithIfNone, distinct, distinct, drop, dropWhile, equals, flatCollect, flatCollect, forEach, forEachWithIndex, getFirst, getLast, groupBy, groupByEach, groupByUniqueKey, hashCode, injectIntoWith, max, max, maxBy, min, min, minBy, newEmpty, partition, partitionWhile, partitionWith, reject, rejectWith, removeIf, removeIfWith, select, selectAndRejectWith, selectInstancesOf, selectWith, shuffleThis, shuffleThis, sortThis, sortThis, sortThisBy, sortThisByBoolean, sortThisByByte, sortThisByChar, sortThisByDouble, sortThisByFloat, sortThisByInt, sortThisByLong, sortThisByShort, subList, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, take, takeWhile, tap, toImmutable, toList, toReversed, toSet, toSortedList, toSortedList, toStack, with, withAll, without, withoutAll, zip, zip, zipWithIndex, zipWithIndex
addAllIterable, aggregateBy, aggregateInPlaceBy, chunk, removeAllIterable, retainAllIterable
appendString, asLazy, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectInt, collectLong, collectShort, containsAllArguments, containsAllIterable, forEach, groupBy, groupByEach, groupByUniqueKey, makeString, makeString, makeString, notEmpty, sumByDouble, sumByFloat, sumByInt, sumByLong, toBag, toMap, toSortedBag, toSortedBag, toSortedBagBy, toSortedListBy, toSortedMap, toSortedMap, toSortedSet, toSortedSet, toSortedSetBy, toString
forEach
addAllIterable, aggregateBy, aggregateInPlaceBy, removeAllIterable, retainAllIterable
replaceAll, sort, spliterator
parallelStream, removeIf, stream
appendString, asLazy, chunk, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectInt, collectLong, collectShort, containsAllArguments, containsAllIterable, groupBy, groupByEach, groupByUniqueKey, makeString, makeString, makeString, notEmpty, sumByDouble, sumByFloat, sumByInt, sumByLong, toBag, toMap, toSortedBag, toSortedBag, toSortedBagBy, toSortedListBy, toSortedMap, toSortedMap, toSortedSet, toSortedSet, toSortedSetBy, toString
forEach
public MutableList<E> clone()
clone
in interface MutableList<E>
clone
in class AbstractMutableList<E>
public int size()
RichIterable
size
in interface Collection<E>
size
in interface List<E>
size
in interface RichIterable<E>
size
in interface BatchIterable<E>
public void resetSize()
public void batchForEach(Procedure<? super E> procedure, int sectionIndex, int sectionCount)
batchForEach
in interface BatchIterable<E>
public int getBatchCount(int batchSize)
getBatchCount
in interface BatchIterable<E>
public CompositeFastList<E> reverseThis()
MutableList
reverseThis
in interface MutableList<E>
reverseThis
in class AbstractMutableList<E>
public void each(Procedure<? super E> procedure)
RichIterable
Example 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 RichIterable<E>
each
in class AbstractMutableList<E>
InternalIterable.forEach(Procedure)
,
Iterable.forEach(java.util.function.Consumer)
public <IV> IV injectInto(IV injectedValue, Function2<? super IV,? super E,? extends IV> function)
RichIterable
injectInto
in interface RichIterable<E>
injectInto
in class AbstractMutableList<E>
public int injectInto(int injectedValue, IntObjectToIntFunction<? super E> function)
RichIterable
injectInto
in interface RichIterable<E>
injectInto
in class AbstractMutableList<E>
public float injectInto(float injectedValue, FloatObjectToFloatFunction<? super E> function)
RichIterable
injectInto
in interface RichIterable<E>
injectInto
in class AbstractMutableList<E>
public long injectInto(long injectedValue, LongObjectToLongFunction<? super E> function)
RichIterable
injectInto
in interface RichIterable<E>
injectInto
in class AbstractMutableList<E>
public double injectInto(double injectedValue, DoubleObjectToDoubleFunction<? super E> function)
RichIterable
injectInto
in interface RichIterable<E>
injectInto
in class AbstractRichIterable<E>
public void forEachWithIndex(ObjectIntProcedure<? super E> objectIntProcedure)
InternalIterable
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() { public void value(Person person, int index) { LOGGER.info("Index: " + index + " person: " + person.getName()); } });
forEachWithIndex
in interface InternalIterable<E>
forEachWithIndex
in interface OrderedIterable<E>
forEachWithIndex
in class AbstractMutableList<E>
public void reverseForEach(Procedure<? super E> procedure)
ReversibleIterable
e.g. people.reverseForEach(new Procedure() { public void value(Person person) { LOGGER.info(person.getName()); } });
reverseForEach
in interface ReversibleIterable<E>
reverseForEach
in class AbstractMutableList<E>
public <P> void forEachWith(Procedure2<? super E,? super P> procedure2, P parameter)
InternalIterable
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() { public void value(Person person, Person other) { if (person.isRelatedTo(other)) { LOGGER.info(person.getName()); } } }, fred);
forEachWith
in interface InternalIterable<E>
forEachWith
in class AbstractMutableList<E>
public boolean isEmpty()
RichIterable
isEmpty
in interface Collection<E>
isEmpty
in interface List<E>
isEmpty
in interface RichIterable<E>
isEmpty
in class AbstractRichIterable<E>
public boolean contains(Object object)
RichIterable
contains
in interface Collection<E>
contains
in interface List<E>
contains
in interface RichIterable<E>
contains
in class AbstractMutableList<E>
public Object[] toArray()
RichIterable
toArray
in interface Collection<E>
toArray
in interface List<E>
toArray
in interface RichIterable<E>
toArray
in class AbstractRichIterable<E>
Collection.toArray()
public boolean add(E object)
add
in interface Collection<E>
add
in interface List<E>
add
in class AbstractMutableCollection<E>
public boolean remove(Object object)
remove
in interface Collection<E>
remove
in interface List<E>
remove
in class AbstractMutableCollection<E>
public boolean addAll(Collection<? extends E> collection)
addAll
in interface Collection<E>
addAll
in interface List<E>
addAll
in class AbstractMutableCollection<E>
public boolean containsAll(Collection<?> collection)
RichIterable
containsAll
in interface Collection<E>
containsAll
in interface List<E>
containsAll
in interface RichIterable<E>
containsAll
in class AbstractMutableList<E>
Collection.containsAll(Collection)
public Object[] toArray(Object[] array)
RichIterable
toArray
in interface Collection<E>
toArray
in interface List<E>
toArray
in interface RichIterable<E>
toArray
in class AbstractRichIterable<E>
Collection.toArray(Object[])
public void addComposited(Collection<? extends E> collection)
public boolean addAll(int index, Collection<? extends E> collection)
public void clear()
public boolean retainAll(Collection<?> collection)
retainAll
in interface Collection<E>
retainAll
in interface List<E>
retainAll
in class AbstractMutableList<E>
public boolean removeAll(Collection<?> collection)
removeAll
in interface Collection<E>
removeAll
in interface List<E>
removeAll
in class AbstractMutableList<E>
public E get(int index)
ListIterable
public int indexOf(Object o)
OrderedIterable
indexOf
in interface List<E>
indexOf
in interface OrderedIterable<E>
indexOf
in class AbstractMutableList<E>
List.indexOf(Object)
public int lastIndexOf(Object o)
ListIterable
lastIndexOf
in interface List<E>
lastIndexOf
in interface ListIterable<E>
lastIndexOf
in class AbstractMutableList<E>
public ListIterator<E> listIterator()
AFAIK list iterator is only commonly used in sorting.
listIterator
in interface List<E>
listIterator
in interface ListIterable<E>
listIterator
in class AbstractMutableList<E>
List.listIterator()
public ListIterator<E> listIterator(int index)
AFAIK list iterator is only commonly used in sorting.
listIterator
in interface List<E>
listIterator
in interface ListIterable<E>
listIterator
in class AbstractMutableList<E>
List.listIterator(int)
public int count(Predicate<? super E> predicate)
RichIterable
Example using a Java 8 lambda expression:
int count = people.count(person -> person.getAddress().getState().getName().equals("New York"));
Example using an anonymous inner class:
int count = people.count(new Predicate<Person>() { public boolean accept(Person person) { return person.getAddress().getState().getName().equals("New York"); } });
count
in interface RichIterable<E>
count
in class AbstractMutableList<E>
public <P> int countWith(Predicate2<? super E,? super P> predicate, P parameter)
RichIterable
e.g. return lastNames.countWith(PredicatesLite.equal(), "Smith");
countWith
in interface RichIterable<E>
countWith
in class AbstractMutableList<E>
public boolean anySatisfy(Predicate<? super E> predicate)
RichIterable
anySatisfy
in interface RichIterable<E>
anySatisfy
in class AbstractMutableList<E>
public <R extends Collection<E>> R select(Predicate<? super E> predicate, R target)
RichIterable
Example using a Java 8 lambda expression:
MutableList<Person> selected = people.select(person -> person.person.getLastName().equals("Smith"), Lists.mutable.empty());
Example using an anonymous inner class:
MutableList<Person> selected = people.select(new Predicate<Person>() { public boolean accept(Person person) { return person.person.getLastName().equals("Smith"); } }, Lists.mutable.empty());
select
in interface RichIterable<E>
select
in class AbstractMutableList<E>
predicate
- a Predicate
to use as the select criteriatarget
- the Collection to append to for all elements in this RichIterable
that meet select criteria predicate
target
, which contains appended elements as a result of the select criteriaRichIterable.select(Predicate)
public <P,R extends Collection<E>> R selectWith(Predicate2<? super E,? super P> predicate, P parameter, R target)
RichIterable
RichIterable.select(Predicate, Collection)
, 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:
MutableList<Person> selected = people.selectWith((Person person, Integer age) -> person.getAge() >= age, Integer.valueOf(18), Lists.mutable.empty());
Example using an anonymous inner class:
MutableList<Person> selected = people.selectWith(new Predicate2<Person, Integer>() { public boolean accept(Person person, Integer age) { return person.getAge() >= age; } }, Integer.valueOf(18), Lists.mutable.empty());
selectWith
in interface RichIterable<E>
selectWith
in class AbstractMutableList<E>
predicate
- a Predicate2
to use as the select criteriaparameter
- a parameter to pass in for evaluation of the second argument P
in predicate
target
- the Collection to append to for all elements in this RichIterable
that meet select criteria predicate
targetCollection
, which contains appended elements as a result of the select criteriaRichIterable.select(Predicate)
,
RichIterable.select(Predicate, Collection)
public <R extends Collection<E>> R reject(Predicate<? super E> predicate, R target)
RichIterable
Example using a Java 8 lambda expression:
MutableList<Person> rejected = people.reject(person -> person.person.getLastName().equals("Smith"), Lists.mutable.empty());
Example using an anonymous inner class:
MutableList<Person> rejected = people.reject(new Predicate<Person>() { public boolean accept(Person person) { return person.person.getLastName().equals("Smith"); } }, Lists.mutable.empty());
reject
in interface RichIterable<E>
reject
in class AbstractMutableList<E>
predicate
- a Predicate
to use as the reject criteriatarget
- the Collection to append to for all elements in this RichIterable
that cause Predicate#accept(Object)
method to evaluate to falsetarget
, which contains appended elements as a result of the reject criteriapublic <P,R extends Collection<E>> R rejectWith(Predicate2<? super E,? super P> predicate, P parameter, R target)
RichIterable
RichIterable.reject(Predicate, Collection)
, 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:
MutableList<Person> rejected = people.rejectWith((Person person, Integer age) -> person.getAge() < age, Integer.valueOf(18), Lists.mutable.empty());
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), Lists.mutable.empty());
rejectWith
in interface RichIterable<E>
rejectWith
in class AbstractMutableList<E>
predicate
- a Predicate2
to use as the reject criteriaparameter
- a parameter to pass in for evaluation of the second argument P
in predicate
target
- the Collection to append to for all elements in this RichIterable
that cause Predicate#accept(Object)
method to evaluate to falsetargetCollection
, which contains appended elements as a result of the reject criteriaRichIterable.reject(Predicate)
,
RichIterable.reject(Predicate, Collection)
public <V,R extends Collection<V>> R collect(Function<? super E,? extends V> function, R target)
RichIterable
RichIterable.collect(Function)
, except that the results are gathered into the specified target
collection.
Example using a Java 8 lambda expression:
MutableList<String> names = people.collect(person -> person.getFirstName() + " " + person.getLastName(), Lists.mutable.empty());
Example using an anonymous inner class:
MutableList<String> names = people.collect(new Function<Person, String>() { public String valueOf(Person person) { return person.getFirstName() + " " + person.getLastName(); } }, Lists.mutable.empty());
collect
in interface RichIterable<E>
collect
in class AbstractMutableList<E>
function
- a Function
to use as the collect transformation functiontarget
- the Collection to append to for all elements in this RichIterable
that meet select criteria function
target
, which contains appended elements as a result of the collect transformationRichIterable.collect(Function)
public <P,A,R extends Collection<A>> R collectWith(Function2<? super E,? super P,? extends A> function, P parameter, R target)
RichIterable
Example using a Java 8 lambda expression:
MutableSet<Integer> integers = Lists.mutable.with(1, 2, 3).collectWith((each, parameter) -> each + parameter, Integer.valueOf(1), Sets.mutable.empty());
Example using an anonymous inner class:
Function2addParameterFunction = new Function2 () { public Integer value(final Integer each, final Integer parameter) { return each + parameter; } }; MutableSet<Integer> integers = Lists.mutable.with(1, 2, 3).collectWith(addParameterFunction, Integer.valueOf(1), Sets.mutable.empty());
collectWith
in interface RichIterable<E>
collectWith
in class AbstractMutableList<E>
function
- a Function2
to use as the collect transformation functionparameter
- a parameter to pass in for evaluation of the second argument P
in function
target
- the Collection to append to for all elements in this RichIterable
that meet select criteria function
targetCollection
, which contains appended elements as a result of the collect transformationpublic <P> boolean anySatisfyWith(Predicate2<? super E,? super P> predicate, P parameter)
RichIterable
anySatisfyWith
in interface RichIterable<E>
anySatisfyWith
in class AbstractMutableList<E>
public boolean allSatisfy(Predicate<? super E> predicate)
RichIterable
allSatisfy
in interface RichIterable<E>
allSatisfy
in class AbstractMutableList<E>
public <P> boolean allSatisfyWith(Predicate2<? super E,? super P> predicate, P parameter)
RichIterable
allSatisfyWith
in interface RichIterable<E>
allSatisfyWith
in class AbstractMutableList<E>
public boolean noneSatisfy(Predicate<? super E> predicate)
RichIterable
noneSatisfy
in interface RichIterable<E>
noneSatisfy
in class AbstractMutableList<E>
public <P> boolean noneSatisfyWith(Predicate2<? super E,? super P> predicate, P parameter)
RichIterable
noneSatisfyWith
in interface RichIterable<E>
noneSatisfyWith
in class AbstractMutableList<E>
public ParallelListIterable<E> asParallel(ExecutorService executorService, int batchSize)
ListIterable
asParallel
in interface ListIterable<E>
asParallel
in class AbstractMutableList<E>
Copyright © 2004–2016. All rights reserved.