To create a new wrapper around an existing List instance, use the adapt(List) factory method.
| Modifier and Type | Field and Description |
|---|---|
| private final List | |
| private static final long |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public static <E> MutableList | |
| public boolean | allSatisfy(Predicate<? super T> predicate)
Overrides org. Implements org. Returns true if the predicate evaluates to true for every element of the iterable or if the iterable is empty. |
| public boolean | anySatisfy(Predicate<? super T> predicate)
Overrides org. Implements org. Returns true if the predicate evaluates to true for any element of the iterable. |
| public ParallelListIterable | asParallel(ExecutorService executorService, int batchSize)
Overrides org. Implements org. Returns a parallel iterable of this ListIterable. |
| public MutableList | asSynchronized()
Implements org. Returns a synchronized wrapper backed by this collection. |
| public MutableList | asUnmodifiable()
Implements org. Returns an unmodifiable view of the list. |
| public MutableList | clone()
Overrides org. Implements org. Creates and returns a copy of this object. |
| public <S> boolean | corresponds(OrderedIterable<S> other, Predicate2<? super T, ? super S> predicate)
Implements org. Returns true if both OrderedIterables have the same length
and |
| public int | count(Predicate<? super T> predicate)
Overrides org. Implements org. Return the total number of elements that answer true to the specified predicate. |
| public T | detect(Predicate<? super T> predicate)
Overrides org. Implements org. Returns the first element of the iterable for which the predicate evaluates to true or null in the case where no element returns true. |
| public T | detectIfNone(Predicate<? super T> predicate, Function0<? extends T> function)
Overrides org. Overrides default org. Returns the first element of the iterable for which the predicate evaluates to true. |
| public int | detectIndex(Predicate<? super T> predicate)
Implements org. Returns the index of the first element of the |
| public int | detectLastIndex(Predicate<? super T> predicate)
Implements org. Returns the index of the last element of the |
| public MutableList | distinct()
Implements org. Returns a new |
| public MutableList | distinct(HashingStrategy<? super T> hashingStrategy)
Implements org. Returns a new |
| public MutableList | drop(int count)
Implements org. Returns an iterable after skipping the first |
| public MutableList | dropWhile(Predicate<? super T> predicate)
Implements org. Returns the final elements that do not satisfy the Predicate. |
| public void | each(Procedure<? super T> procedure)
Overrides org. Implements org. The procedure is executed for each element in the iterable. |
| public void | forEach(int fromIndex, int toIndex, Procedure<? super T> procedure)
Implements org. Iterates over the section of the iterable covered by the specified inclusive indexes. |
| public void | forEachWithIndex(ObjectIntProcedure<? super T> objectIntProcedure)
Overrides org. Implements org. Iterates over the iterable passing each element and the current relative int index to the specified instance of ObjectIntProcedure. |
| public void | forEachWithIndex(int fromIndex, int toIndex, ObjectIntProcedure<? super T> objectIntProcedure)
Implements org. Iterates over the section of the iterable covered by the specified inclusive indexes. |
| protected List | getDelegate()
Implements abstract org.
|
| public <IV> IV | injectInto(IV injectedValue, Function2<? super IV, ? super T, ? extends IV> function)
Overrides org. Implements org. Returns the final result of evaluating function using each element of the iterable and the previous evaluation result as the parameters. |
| public MutableList | newEmpty()
Implements org.
Deprecated
use
FastList#newList() instead (inlineable)
Creates a new empty mutable version of the same collection type. |
| public boolean | noneSatisfy(Predicate<? super T> predicate)
Overrides org. Implements org. Returns true if the predicate evaluates to false for every element of the iterable or if the iterable is empty. |
| public PartitionMutableList | partitionWhile(Predicate<? super T> predicate)
Implements org. Returns a Partition of the initial elements that satisfy the Predicate and the remaining elements. |
| public void | reverseForEach(Procedure<? super T> procedure)
Overrides default org. Evaluates the procedure for each element of the list iterating in reverse order. |
| public void | reverseForEachWithIndex(ObjectIntProcedure<? super T> procedure)
Overrides default org. Evaluates the procedure for each element and it's index in reverse order. |
| public <S> MutableList | selectInstancesOf(Class<S> clazz)
Overrides org. Implements org. Returns all elements of the source collection that are instances of the Class |
| public void | sort(Comparator<? super T> comparator)
Overrides default java. Sorts this list according to the order induced by the specified
|
| public ListAdapter | sortThis(Comparator<? super T> comparator)
Overrides default org. Sorts the internal data structure of this list and returns the list itself as a convenience. |
| public ListAdapter | sortThis()
Overrides default org. Sorts the internal data structure of this list and returns the list itself as a convenience. |
| public MutableList | take(int count)
Implements org. Returns the first |
| public MutableList | takeWhile(Predicate<? super T> predicate)
Implements org. Returns the initial elements that satisfy the Predicate. |
| public ImmutableList | toImmutable()
Overrides default org. Implements org. Returns an immutable copy of this list. |
| public ListAdapter | with(T element)
Overrides default org. Implements org. This method allows mutable and fixed size collections the ability to add elements to their existing elements. |
| public ListAdapter | |
| public ListAdapter | |
| public ListAdapter | with(T... elements)
Overrides default org. Implements org. This method allows mutable and fixed size collections the ability to add elements to their existing elements. |
| public ListAdapter | withAll(Iterable<? extends T> elements)
Overrides default org. Implements org. This method allows mutable and fixed size collections the ability to add multiple elements to their existing elements. |
| public ListAdapter | without(T element)
Overrides default org. Implements org. This method allows mutable and fixed size collections the ability to remove elements from their existing elements. |
| public ListAdapter | withoutAll(Iterable<? extends T> elements)
Overrides default org. Implements org. This method allows mutable and fixed size collections the ability to remove multiple elements from their existing elements. |
| delegate | back to summary |
|---|---|
| private final List<T> delegate | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID | |
| ListAdapter | back to summary |
|---|---|
| pack-priv ListAdapter(List<T> newDelegate) | |
| adapt | back to summary |
|---|---|
| public static <E> MutableList | |
| allSatisfy | back to summary |
|---|---|
| public boolean allSatisfy(Predicate<? super T> predicate) Overrides org. Implements org. Doc from org. Returns true if the predicate evaluates to true for every element of the iterable or if the iterable is empty. Otherwise, returns false.
| |
| anySatisfy | back to summary |
|---|---|
| public boolean anySatisfy(Predicate<? super T> predicate) Overrides org. Implements org. Doc from org. Returns true if the predicate evaluates to true for any element of the iterable. Returns false if the iterable is empty, or if no element returned true when evaluating the predicate.
| |
| asParallel | back to summary |
|---|---|
| public ParallelListIterable Overrides org. Implements org. Doc from org. Returns a parallel iterable of this ListIterable.
| |
| asSynchronized | back to summary |
|---|---|
| public MutableList Implements org. Doc from org. Returns a synchronized wrapper backed by this collection. This is the equivalent of using
MutableCollection synchedCollection = collection.asSynchronized();
...
synchedCollection.forEach(each -> ... );
synchedCollection.select(each -> ... );
synchedCollection.collect(each -> ... );
If you want to iterate using an imperative style, you must protect external iterators using
a synchronized block. This includes explicit iterators as well as JDK 5 style for loops.
| |
| asUnmodifiable | back to summary |
|---|---|
| public MutableList Implements org. Doc from org. Returns an unmodifiable view of the list.
| |
| clone | back to summary |
|---|---|
| public MutableList Overrides org. Implements org. Doc from java. Creates and returns a copy of this object. The precise meaning
of "copy" may depend on the class of the object. The general
intent is that, for any object will be true, and that the expression:x.clone() != x will bex.clone().getClass() == x.getClass() true, but these are not absolute requirements.
While it is typically the case that:
will bex.clone().equals(x) true, this is not an absolute requirement.
By convention, the returned object should be obtained by calling
By convention, the object returned by this method should be independent
of this object (which is being cloned). To achieve this independence,
it may be necessary to modify one or more fields of the object returned
by
| |
| corresponds | back to summary |
|---|---|
| public <S> boolean corresponds(OrderedIterable<S> other, Predicate2<? super T, ? super S> predicate) Implements org. Doc from org. Returns true if both OrderedIterables have the same length
and
| |
| count | back to summary |
|---|---|
| public int count(Predicate<? super T> predicate) Overrides org. Implements org. Doc from org. Return the total number of elements that answer true to the specified predicate. Example using a Java 8 lambda expression:
int count =
people.count(person -> person.getAddress().getState().getName().equals("New York"));
| |
| detect | back to summary |
|---|---|
| public T detect(Predicate<? super T> predicate) Overrides org. Implements org. Doc from org. Returns the first element of the iterable for which the predicate evaluates to true or null in the case where no element returns true. This method is commonly called find. Example using a Java 8 lambda expression:
Person person =
people.detect(person -> person.getFirstName().equals("John") && person.getLastName().equals("Smith"));
| |
| detectIfNone | back to summary |
|---|---|
| public T detectIfNone(Predicate<? super T> predicate, Function0<? extends T> function) Overrides org. Overrides default org. Doc from org. Returns the first element of the iterable for which the predicate evaluates to true. If no element matches the predicate, then returns the value of applying the specified function.
| |
| detectIndex | back to summary |
|---|---|
| public int detectIndex(Predicate<? super T> predicate) Implements org. Doc from org. Returns the index of the first element of the
| |
| detectLastIndex | back to summary |
|---|---|
| public int detectLastIndex(Predicate<? super T> predicate) Implements org. Doc from org. Returns the index of the last element of the
| |
| distinct | back to summary |
|---|---|
| public MutableList Implements org. Doc from org. Returns a new
| |
| distinct | back to summary |
|---|---|
| public MutableList Implements org. Doc from org. Returns a new
| |
| drop | back to summary |
|---|---|
| public MutableList Implements org. Doc from org. Returns an iterable after skipping the first
| |
| dropWhile | back to summary |
|---|---|
| public MutableList Implements org. Doc from org. Returns the final elements that do not satisfy the Predicate. Short circuits at the first element which does satisfy the Predicate.
| |
| each | back to summary |
|---|---|
| public void each(Procedure<? super T> procedure) Overrides org. Implements org. Doc from org. The procedure is executed for each element in the iterable. Example using a Java 8 lambda expression: people.each(person -> LOGGER.info(person.getName()));This method is a variant of InternalIterable#forEach(Procedure)
that has a signature conflict with Iterable#forEach(java..
| |
| forEach | back to summary |
|---|---|
| public void forEach(int fromIndex, int toIndex, Procedure<? super T> procedure) Implements org. Doc from org. Iterates over the section of the iterable covered by the specified inclusive indexes. The indexes are both inclusive. e.g. OrderedIterable<Person> people = FastList.newListWith(ted, mary, bob, sally) people.forEach(0, 1, person -> LOGGER.info(person.getName())); This code would output ted and mary's names.
| |
| forEachWithIndex | back to summary |
|---|---|
| public void forEachWithIndex(ObjectIntProcedure<? super T> objectIntProcedure) Overrides org. Implements org. Doc from org. Iterates over the iterable passing each element and the current relative int index to the specified instance of ObjectIntProcedure. Example using a Java 8 lambda:
people.forEachWithIndex((Person person, int index) -> LOGGER.info("Index: " + index + " person: " + person.getName()));
Example using an anonymous inner class:
people.forEachWithIndex(new ObjectIntProcedure<Person>()
{
public void value(Person person, int index)
{
LOGGER.info("Index: " + index + " person: " + person.getName());
}
});
| |
| forEachWithIndex | back to summary |
|---|---|
| public void forEachWithIndex(int fromIndex, int toIndex, ObjectIntProcedure<? super T> objectIntProcedure) Implements org. Doc from org. Iterates over the section of the iterable covered by the specified inclusive indexes. The indexes are both inclusive. e.g. OrderedIterable<People> people = FastList.newListWith(ted, mary, bob, sally) people.forEachWithIndex(0, 1, (person, index) -> LOGGER.info(person.getName())); This code would output ted and mary's names.
| |
| getDelegate | back to summary |
|---|---|
| protected List Implements abstract org.
| |
| injectInto | back to summary |
|---|---|
| public <IV> IV injectInto(IV injectedValue, Function2<? super IV, ? super T, ? extends IV> function) Overrides org. Implements org. Doc from org. Returns the final result of evaluating function using each element of the iterable and the previous evaluation result as the parameters. The injected value is used for the first parameter of the first evaluation, and the current item in the iterable is used as the second parameter. This method is commonly called fold or sometimes reduce.
| |
| newEmpty | back to summary |
|---|---|
| public MutableList Implements org. Doc from org. Deprecated use Creates a new empty mutable version of the same collection type. For example, if this instance is a FastList, this method will return a new empty FastList. If the class of this instance is immutable or fixed size (i.e. SingletonList) then a mutable alternative to the class will be provided.
| |
| noneSatisfy | back to summary |
|---|---|
| public boolean noneSatisfy(Predicate<? super T> predicate) Overrides org. Implements org. Doc from org. Returns true if the predicate evaluates to false for every element of the iterable or if the iterable is empty. Otherwise, returns false.
| |
| partitionWhile | back to summary |
|---|---|
| public PartitionMutableList Implements org. Doc from org. Returns a Partition of the initial elements that satisfy the Predicate and the remaining elements. Short circuits at the first element which does satisfy the Predicate.
| |
| reverseForEach | back to summary |
|---|---|
| public void reverseForEach(Procedure<? super T> procedure) Overrides default org. Doc from org. Evaluates the procedure for each element of the list iterating in reverse order. e.g. people.reverseForEach(person -> LOGGER.info(person.getName()));
| |
| reverseForEachWithIndex | back to summary |
|---|---|
| public void reverseForEachWithIndex(ObjectIntProcedure<? super T> procedure) Overrides default org. Doc from org. Evaluates the procedure for each element and it's index in reverse order. e.g.
people.reverseForEachWithIndex((person, index) ->
LOGGER.info("Index: " + index + " person: " + person.getName()));
| |
| selectInstancesOf | back to summary |
|---|---|
| public <S> MutableList Overrides org. Implements org. Doc from org. Returns all elements of the source collection that are instances of the Class
RichIterable<Integer> integers =
List.mutable.with(new Integer(0), new Long(0L), new Double(0.0)).selectInstancesOf(Integer.class);
Co-variant example for MutableCollection:
MutableCollection<Integer> integers =
List.mutable.with(new Integer(0), new Long(0L), new Double(0.0)).selectInstancesOf(Integer.class);
| |
| sort | back to summary |
|---|---|
| public void sort(Comparator<? super T> comparator) Overrides default java. Doc from java. Sorts this list according to the order induced by the specified
All elements in this list must be mutually comparable using the
specified comparator (that is, If the specified comparator is This list must be modifiable, but need not be resizable.
| |
| sortThis | back to summary |
|---|---|
| public ListAdapter Overrides default org. Doc from org. Sorts the internal data structure of this list and returns the list itself as a convenience.
| |
| sortThis | back to summary |
|---|---|
| public ListAdapter Overrides default org. Doc from org. Sorts the internal data structure of this list and returns the list itself as a convenience.
| |
| take | back to summary |
|---|---|
| public MutableList Implements org. Doc from org. Returns the first
| |
| takeWhile | back to summary |
|---|---|
| public MutableList Implements org. Doc from org. Returns the initial elements that satisfy the Predicate. Short circuits at the first element which does not satisfy the Predicate.
| |
| toImmutable | back to summary |
|---|---|
| public ImmutableList Overrides default org. Implements org. Doc from org. Returns an immutable copy of this list. If the list is immutable, it returns itself.
| |
| with | back to summary |
|---|---|
| public ListAdapter Overrides default org. Implements org. Doc from org. This method allows mutable and fixed size collections the ability to add elements to their existing elements. In order to support fixed size a new instance of a collection would have to be returned taking the elements of the original collection and appending the new element to form the new collection. In the case of mutable collections, the original collection is modified, and is returned. In order to use this method properly with mutable and fixed size collections the following approach must be taken:
MutableCollection<String> list = list.with("1");
list = list.with("2");
return list;
In the case of 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.
| |
| with | back to summary |
|---|---|
| public ListAdapter | |
| with | back to summary |
|---|---|
| public ListAdapter | |
| with | back to summary |
|---|---|
| public ListAdapter Overrides default org. Implements org. Doc from org. This method allows mutable and fixed size collections the ability to add elements to their existing elements. In order to support fixed size a new instance of a collection would have to be returned taking the elements of the original collection and appending the new element to form the new collection. In the case of mutable collections, the original collection is modified, and is returned. In order to use this method properly with mutable and fixed size collections the following approach must be taken:
MutableCollection<String> list = list.with("1");
list = list.with("2");
return list;
In the case of 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.
| |
| withAll | back to summary |
|---|---|
| public ListAdapter Overrides default org. Implements org. Doc from org. This method allows mutable and fixed size collections the ability to add multiple elements to their existing elements. In order to support fixed size a new instance of a collection would have to be returned taking the elements of the original collection and appending the new elements to form the new collection. In the case of mutable collections, the original collection is modified, and is returned. In order to use this method properly with mutable and fixed size collections the following approach must be taken:
MutableCollection<String> list = list.withAll(FastList.newListWith("1", "2"));
In the case of 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.
| |
| without | back to summary |
|---|---|
| public ListAdapter Overrides default org. Implements org. Doc from org. This method allows mutable and fixed size collections the ability to remove elements from their existing elements. In order to support fixed size a new instance of a collection would have to be returned containing the elements that would be left from the original collection after calling remove. In the case of mutable collections, the original collection is modified, and is returned. In order to use this method properly with mutable and fixed size collections the following approach must be taken:
MutableCollection<String> list = list.without("1");
list = list.without("2");
return list;
In the case of 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.
| |
| withoutAll | back to summary |
|---|---|
| public ListAdapter Overrides default org. Implements org. Doc from org. This method allows mutable and fixed size collections the ability to remove multiple elements from their existing elements. In order to support fixed size a new instance of a collection would have to be returned containing the elements that would be left from the original collection after calling removeAll. In the case of mutable collections, the original collection is modified, and is returned. In order to use this method properly with mutable and fixed size collections the following approach must be taken:
MutableCollection<String> list = list.withoutAll(FastList.newListWith("1", "2"));
In the case of 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.
| |