List instances.
| Modifier and Type | Class and Description |
|---|---|
| private static class | ListUtils.CharSequenceAsList
A simple wrapper to use a CharSequence as List. |
| private static class | |
| private static class |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static < the element type T> List | Returns: an empty list if the argument isnullthe list, possibly list, final List<T> nullthe returned values if list is defaultList)nullReturns either the passed in list, or if the list is |
| public static < the element type T> List | Returns: an empty list if the argument isnullthe list, possibly list)nullReturns an immutable empty list if the argument is |
| public static < the element type E> List | Returns: a fixed-size list backed by that listthe list whose size to fix, must not be null list)Returns a fixed-sized list backed by the given list. |
| public static int | Returns: the hash codethe list to generate the hashCode for, may be null list)Generates a hash code using the algorithm specified in
|
| public static < the element type E> int | Returns: the first index of an Object in the List which matches the predicate or -1 if none could be foundthe List to search, may be null list, final Predicate<E> the predicate to use, may be null predicate)Finds the first index in the given List which matches the given predicate. |
| public static < the element type E> List | Returns: the intersection of those two liststhe first list list1, final List<? extends E> the second list list2)Returns a new list containing all elements that are contained in both given lists. |
| public static boolean | Returns: whether the lists are equal by value comparisonthe first list, may be null list1, final Collection<?> the second list, may be null list2)Tests two lists for value-equality as per the equality contract in
|
| public static < the element type E> List | |
| public static < the element type E> List | Returns: a lazy list backed by the given listthe list to make lazy, must not be null list, final Transformer<Integer, ? extends E> the transformer for creating new objects, must not be null transformer)Returns a "lazy" list whose elements will be created on demand. |
| public static < the element type E> List | Returns: the longest common subsequencethe first list a, final List<E> the second list b)Returns the longest common subsequence (LCS) of two sequences (lists). |
| public static < the element type E> List | Returns: the longest common subsequencethe first list a, final List<E> the second list b, final Equator<? super E> the equator used to test object equality equator)Returns the longest common subsequence (LCS) of two sequences (lists). |
| public static String | Returns: the longest common subsequence asStringthe first sequence a, final CharSequence the second sequence b)Returns the longest common subsequence (LCS) of two |
| public static < the element type T> List | |
| public static < the element type E> List | Returns: a predicated list backed by the given listthe list to predicate, must not be null list, final Predicate<E> the predicate for the list, must not be null predicate)Returns a predicated (validating) list backed by the given list. |
| public static < the element type E> List | Returns: aList containing all the elements of c except
any elements that also occur in remove.the collection from which items are removed (in the returned collection) collection, final Collection<?> the items to be removed from the returned remove)collectionRemoves the elements in |
| public static < the element type E> List | Returns: aList containing all the elements of c
that occur at least once in retain.the collection whose contents are the target of the #retailAll operation collection, final Collection<?> the collection containing the elements to be retained in the returned collection retain)Returns a List containing all the elements in |
| public static < the element type E> List | Returns: the elements matching the predicate (new list)the collection to get the input from, may not be null inputCollection, final Predicate<? super E> the predicate to use, may be null predicate)Selects all elements from input collection which match the given predicate into an output list. |
| public static < the element type E> List | Returns: the elements not matching the predicate (new list)the collection to get the input from, may not be null inputCollection, final Predicate<? super E> the predicate to use, may be null predicate)Selects all elements from inputCollection which don't match the given predicate into an output collection. |
| public static < the element type E> List | |
| public static < the element type E> List | |
| public static < the element type E> List | Returns: a synchronized list backed by the given listthe list to synchronize, must not be null list)Returns a synchronized list backed by the given list. |
| public static < the element type E> List | Returns: a transformed list backed by the given listthe list to predicate, must not be null list, final Transformer<? super E, ? extends E> the transformer for the list, must not be null transformer)Returns a transformed list backed by the given list. |
| public static < the element type E> List | |
| public static < the element type E> List | Returns: an unmodifiable list backed by the given listthe list to make unmodifiable, must not be null list)Returns an unmodifiable list backed by the given list. |
| ListUtils | back to summary |
|---|---|
| private ListUtils()
| |
| defaultIfNull | back to summary |
|---|---|
| public static <T> List Returns either the passed in list, or if the list is | |
| emptyIfNull | back to summary |
|---|---|
| public static <T> List Returns an immutable empty list if the argument is | |
| fixedSizeList | back to summary |
|---|---|
| public static <E> List Returns a fixed-sized list backed by the given list.
Elements may not be added or removed from the returned list, but
existing elements can be changed (for instance, via the
| |
| hashCodeForList | back to summary |
|---|---|
| public static int hashCodeForList(final Collection<?> list) Generates a hash code using the algorithm specified in
This method is useful for implementing
| |
| indexOf | back to summary |
|---|---|
| public static <E> int indexOf(final List<E> list, final Predicate<E> predicate) Finds the first index in the given List which matches the given predicate. If the input List or predicate is null, or no element of the List matches the predicate, -1 is returned. | |
| intersection | back to summary |
|---|---|
| public static <E> List Returns a new list containing all elements that are contained in both given lists.
| |
| isEqualList | back to summary |
|---|---|
| public static boolean isEqualList(final Collection<?> list1, final Collection<?> list2) Tests two lists for value-equality as per the equality contract in
This method is useful for implementing The relevant text (slightly paraphrased as this is a static method) is: Compares the two list objects for equality. Returns Note The behaviour of this method is undefined if the lists are modified during the equals comparison.
| |
| lazyList | back to summary |
|---|---|
| public static <E> List Returns a "lazy" list whose elements will be created on demand.
When the index passed to the returned list's For instance:
Factory<Date> factory = new Factory<Date>() {
public Date create() {
return new Date();
}
}
List<Date> lazy = ListUtils.lazyList(new ArrayList<Date>(), factory);
Date date = lazy.get(3);
After the above code is executed, date will refer to
a new Date instance. Furthermore, that Date
instance is the fourth element in the list. The first, second,
and third element are all set to null.
| |
| lazyList | back to summary |
|---|---|
| public static <E> List Returns a "lazy" list whose elements will be created on demand.
When the index passed to the returned list's For instance: List<Integer> hours = Arrays.asList(7, 5, 8, 2); Transformer<Integer,Date> transformer = input -> LocalDateTime.now().withHour(hours.get(input)); List<LocalDateTime> lazy = ListUtils.lazyList(new ArrayList<LocalDateTime>(), transformer); Date date = lazy.get(3);After the above code is executed, date will refer to
a new Date instance. Furthermore, that Date
instance is the fourth element in the list. The first, second,
and third element are all set to null.
| |
| longestCommonSubsequence | back to summary |
|---|---|
| public static <E> List Returns the longest common subsequence (LCS) of two sequences (lists).
| |
| longestCommonSubsequence | back to summary |
|---|---|
| public static <E> List Returns the longest common subsequence (LCS) of two sequences (lists).
| |
| longestCommonSubsequence | back to summary |
|---|---|
| public static String longestCommonSubsequence(final CharSequence a, final CharSequence b) Returns the longest common subsequence (LCS) of two
This is a convenience method for using
| |
| partition | back to summary |
|---|---|
| public static <T> List Returns consecutive
The outer list is unmodifiable, but reflects the latest state of the
source list. The inner lists are sublist views of the original list,
produced on demand using Adapted from http://code.google.com/p/guava-libraries/
| |
| predicatedList | back to summary |
|---|---|
| public static <E> List Returns a predicated (validating) list backed by the given list. Only objects that pass the test in the given predicate can be added to the list. Trying to add an invalid object results in an IllegalArgumentException. It is important not to use the original list after invoking this method, as it is a backdoor for adding invalid objects.
| |
| removeAll | back to summary |
|---|---|
| public static <E> List Removes the elements in
This implementation iterates over
| |
| retainAll | back to summary |
|---|---|
| public static <E> List Returns a List containing all the elements in
This implementation iterates over
| |
| select | back to summary |
|---|---|
| public static <E> List Selects all elements from input collection which match the given predicate into an output list.
A
| |
| selectRejected | back to summary |
|---|---|
| public static <E> List Selects all elements from inputCollection which don't match the given predicate into an output collection.
If the input predicate is
| |
| subtract | back to summary |
|---|---|
| public static <E> List Subtracts all elements in the second list from the first list, placing the results in a new list.
This differs from
| |
| sum | back to summary |
|---|---|
| public static <E> List Returns the sum of the given lists. This is their intersection subtracted from their union.
| |
| synchronizedList | back to summary |
|---|---|
| public static <E> List Returns a synchronized list backed by the given list. You must manually synchronize on the returned list's iterator to avoid non-deterministic behavior:
List list = ListUtils.synchronizedList(myList);
synchronized (list) {
Iterator i = list.iterator();
while (i.hasNext()) {
process (i.next());
}
}
This method is just a wrapper for Collections#synchronizedList(List).
| |
| transformedList | back to summary |
|---|---|
| public static <E> List Returns a transformed list backed by the given list. This method returns a new list (decorating the specified list) that will transform any new entries added to it. Existing entries in the specified list will not be transformed. Each object is passed through the transformer as it is added to the List. It is important not to use the original list after invoking this method, as it is a backdoor for adding untransformed objects.
Existing entries in the specified list will not be transformed.
If you want that behaviour, see
| |
| union | back to summary |
|---|---|
| public static <E> List Returns a new list containing the second list appended to the
first list. The
| |
| unmodifiableList | back to summary |
|---|---|
| public static <E> List Returns an unmodifiable list backed by the given list. This method uses the implementation in the decorators subpackage.
| |
| Modifier and Type | Field and Description |
|---|---|
| private final CharSequence |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public Character | get(final int
index of the element to return index)Implements abstract java. Implements java. |
| public int | size()
Implements abstract java. Implements java. |
| sequence | back to summary |
|---|---|
| private final CharSequence sequence | |
| CharSequenceAsList | back to summary |
|---|---|
| public CharSequenceAsList(final CharSequence sequence) | |
| get | back to summary |
|---|---|
| public Character get(final int index) Implements abstract java. Implements java. Doc from java. Returns the element at the specified position in this list.
| |
| size | back to summary |
|---|---|
| public int size() Implements abstract java. Implements java. Doc from java. Returns the number of elements in this list. If this list contains
more than
| |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public List | |
| public void | visitDeleteCommand(final E
object to delete (this object comes from the first sequence) object)Implements org. |
| public void | visitInsertCommand(final E
object to insert (this object comes from the second sequence) object)Implements org. |
| public void | visitKeepCommand(final E
object to keep (this object comes from the first sequence) object)Implements org. |
| sequence | back to summary |
|---|---|
| private final ArrayList<E> sequence | |
| LcsVisitor | back to summary |
|---|---|
| public LcsVisitor() | |
| getSubSequence | back to summary |
|---|---|
| public List | |
| visitDeleteCommand | back to summary |
|---|---|
| public void visitDeleteCommand(final E object) Implements org. Doc from org. Method called when a delete command is encountered.
| |
| visitInsertCommand | back to summary |
|---|---|
| public void visitInsertCommand(final E object) Implements org. Doc from org. Method called when an insert command is encountered.
| |
| visitKeepCommand | back to summary |
|---|---|
| public void visitKeepCommand(final E object) Implements org. Doc from org. Method called when a keep command is encountered.
| |
List.
| Modifier and Type | Field and Description |
|---|---|
| private final List | |
| private final int |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public List | get(final int
index of the element to return index)Implements abstract java. Implements java. |
| public boolean | isEmpty()
Overrides java. Implements java. true if this list contains no elements.
|
| public int | size()
Implements abstract java. Implements java. |
| list | back to summary |
|---|---|
| private final List<T> list | |
| size | back to summary |
|---|---|
| private final int size | |
| Partition | back to summary |
|---|---|
| private Partition(final List<T> list, final int size) | |
| get | back to summary |
|---|---|
| public List Implements abstract java. Implements java. Doc from java. Returns the element at the specified position in this list.
| |
| isEmpty | back to summary |
|---|---|
| public boolean isEmpty() Overrides java. Implements java. Doc from java. Returns
| |
| size | back to summary |
|---|---|
| public int size() Implements abstract java. Implements java. Doc from java. Returns the number of elements in this list. If this list contains
more than
| |