Package panda.utilities.collection
Class Lists
java.lang.Object
panda.utilities.collection.Lists
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Tadd(Collection<T> list, T element) Add element to the given collection and get added value as resultstatic <T> TGet element of list at the given position without risk ofArrayIndexOutOfBoundsExceptionstatic <T> List<T>mutableOf(T... elements) Create mutable list from varargsstatic <T> List<T>Reverse the provided list and return itsstatic <T> voidsort(Comparator<T> comparator, List<? extends T>... collections) Sort similar lists using the same comparatorstatic <T> List<T>[]Split list by the given delimiterstatic <T> List<T>Returns a view of the portion of the given liststatic <T> ArrayList<T>Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex exclusive.
-
Method Details
-
add
Add element to the given collection and get added value as result- Type Parameters:
T- type of element- Parameters:
list- the collection to useelement- the element to add- Returns:
- the element to add
-
subList
Returns a view of the portion of the given list- Type Parameters:
T- type of list- Parameters:
list- the list to usestartIndex- low endpoint (inclusive) of the subList- Returns:
- a view of the specified range within this list
-
subList
Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex exclusive. The returned array list is independent collection and changes does not affect the original list.- Type Parameters:
T- type of list- Parameters:
list- the list to use as source liststartIndex- the start indexendIndex- the end index- Returns:
- a new list
-
sort
@SafeVarargs public static <T> void sort(Comparator<T> comparator, List<? extends T>... collections) Sort similar lists using the same comparator- Type Parameters:
T- type of the lists- Parameters:
comparator- the comparator to usecollections- the array of lists to sort
-
reverse
Reverse the provided list and return its- Type Parameters:
T- type of the list- Parameters:
list- the list to reverse- Returns:
- the reversed list
-
split
Split list by the given delimiter- Type Parameters:
T- type of list- Parameters:
list- the list to splitdelimiter- the object to use as delimiter- Returns:
- the array of lists
-
mutableOf
Create mutable list from varargs- Type Parameters:
T- type of the list- Parameters:
elements- to add to the array- Returns:
- created list
-
get
Get element of list at the given position without risk ofArrayIndexOutOfBoundsException- Type Parameters:
T- type of the list- Parameters:
list- the list to processindex- the index of element to get- Returns:
- the element at the index position, null if the index is less than 0 or greater than the size of the specified list
-