Package org.pepsoft.util
Class CollectionUtils
java.lang.Object
org.pepsoft.util.CollectionUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic BitSetbitSetOf(int... values) static <E> ArrayList<E>Null-safe method for copying aList.static <K,V> HashMap<K, V> Null-safe method for copying aMap.static <E> HashSet<E>Null-safe method for copying aSet.static <T> List<T>Creates an unmodifiable and efficient (forRandomAccesslists)Listwhich is the concatenation of several otherLists.static intmax(int[] values) Returns the highest value from an array ofints, orInteger.MIN_VALUEif the array is empty.static <T> List<T>nullAnd(Collection<T> collection) Prepends anullto a collection.static intunsignedMax(byte[] values) Returns the highest value from an array ofbytes, interpreted as unsigned values, orInteger.MIN_VALUEif the array is empty.static intunsignedMax(short[] values) Returns the highest value from an array ofshorts, interpreted as unsigned values, orInteger.MIN_VALUEif the array is empty.
-
Method Details
-
bitSetOf
-
listOf
Creates an unmodifiable and efficient (forRandomAccesslists)Listwhich is the concatenation of several otherLists. -
max
public static int max(int[] values) Returns the highest value from an array ofints, orInteger.MIN_VALUEif the array is empty. -
unsignedMax
public static int unsignedMax(short[] values) Returns the highest value from an array ofshorts, interpreted as unsigned values, orInteger.MIN_VALUEif the array is empty. -
unsignedMax
public static int unsignedMax(byte[] values) Returns the highest value from an array ofbytes, interpreted as unsigned values, orInteger.MIN_VALUEif the array is empty. -
nullAnd
Prepends anullto a collection.- Type Parameters:
T- The type of collection.- Parameters:
collection- The collection to which to prepend anull.- Returns:
- A list containing a
nulland then the contents ofcollection.
-
copyOf
Null-safe method for copying aList.- Type Parameters:
E- The element type of the list.- Parameters:
list- The list to copy.- Returns:
- A new
ArrayListwith the contents of the provided list, ornulliflistwas null.
-
copyOf
Null-safe method for copying aSet.- Type Parameters:
E- The element type of the set.- Parameters:
set- The set to copy.- Returns:
- A new
HashSetwith the contents of the provided set, ornullifsetwas null.
-
copyOf
Null-safe method for copying aMap.- Type Parameters:
K- The key type of the map.V- The value type of the map.- Parameters:
map- The map to copy.- Returns:
- A new
HashMapwith the contents of the provided map, ornullifmapwas null.
-