public final class ListUtils
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static <T> int |
addAll(java.util.List<T> list,
java.lang.Object array)
Add all items from the array to the list.
|
static <T> void |
flat(java.util.List<T> targetList,
java.util.List<T> sourceList,
int depth)
The flat() method of Array instances creates a new array with all sub-array elements concatenated
into it recursively up to the specified depth.
|
static <T> boolean |
includes(java.util.List<T> list,
T element,
int fromIndex)
The includes() method of Array instances determines whether an array includes a certain value among its entries,
returning true or false as appropriate.
|
static <T> int |
indexOf(java.util.List<T> list,
T element,
int fromIndex)
The indexOf() method of Array instances returns the first index
at which a given element can be found in the array, or -1 if it is not present.
|
static boolean |
isEmpty(java.util.List<?> list)
Is empty.
|
static boolean |
isNotEmpty(java.util.List<?> list)
Is not empty.
|
static <T> int |
lastIndexOf(java.util.List<T> list,
T element,
int fromIndex)
The lastIndexOf() method of Array instances returns the last index at which a given element can be found
in the array, or -1 if it is not present.
|
static <T> T |
pop(java.util.List<T> list)
The pop() method of Array instances removes the last element from an array and returns that element.
|
static <T> int |
push(java.util.List<T> list,
T... elements)
The push() method of Array instances adds the specified elements to the end of an array
and returns the new length of the array.
|
static <T> T |
shift(java.util.List<T> list)
The shift() method of Array instances removes the first element from an array and
returns that removed element.
|
static <T> int |
unshift(java.util.List<T> list,
T... elements)
The unshift() method of Array instances adds the specified elements to the beginning of an array and
returns the new length of the array.
|
public static <T> int addAll(java.util.List<T> list, java.lang.Object array)
T
- the type parameterlist
- the listarray
- the arraypublic static <T> void flat(java.util.List<T> targetList, java.util.List<T> sourceList, int depth)
T
- the type parametertargetList
- the target listsourceList
- the source listdepth
- the depthpublic static <T> boolean includes(java.util.List<T> list, T element, int fromIndex)
T
- the type parameterlist
- the listelement
- the elementfromIndex
- the from indexpublic static <T> int indexOf(java.util.List<T> list, T element, int fromIndex)
T
- the type parameterlist
- the listelement
- the elementfromIndex
- the from indexpublic static boolean isEmpty(java.util.List<?> list)
list
- the listpublic static boolean isNotEmpty(java.util.List<?> list)
list
- the listpublic static <T> int lastIndexOf(java.util.List<T> list, T element, int fromIndex)
T
- the type parameterlist
- the listelement
- the elementfromIndex
- the from indexpublic static <T> T pop(java.util.List<T> list)
T
- the type parameterlist
- the listpublic static <T> int push(java.util.List<T> list, T... elements)
T
- the type parameterlist
- the listelements
- the elementspublic static <T> T shift(java.util.List<T> list)
T
- the type parameterlist
- the listpublic static <T> int unshift(java.util.List<T> list, T... elements)
T
- the type parameterlist
- the listelements
- the elements