Package org.locationtech.jts.jump.util
Class CollectionUtil
- java.lang.Object
-
- org.locationtech.jts.jump.util.CollectionUtil
-
public class CollectionUtil extends Object
-
-
Constructor Summary
Constructors Constructor Description CollectionUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidaddIfNotNull(Object item, Collection collection)static Collectioncollect(Collection collection, Block block)The Smalltalk #collect method.static Listcombinations(List original)Returns a List of Lists: all combinations of the elements of the given List.static Listcombinations(List original, int maxCombinationSize)Returns a List of Lists: all combinations of the elements of the given List.static Listcombinations(List original, int maxCombinationSize, Object mandatoryItem)Returns a List of Lists: all combinations of the elements of the given List.static Collectionconcatenate(Collection collections)static booleancontainsReference(Object[] objects, Object o)static MapcreateMap(Class mapClass, Object[] alternatingKeysAndValues)static MapcreateMap(Object[] alternatingKeysAndValues)static CollectionfilterByClass(Collection collection, Class c)Modifies and returns the collection.static Objectget(Class c, Map map)static ObjectifNotIn(Object o, Collection c, Object alternative)static intindexOf(Object o, Object[] objects)static Mapinverse(Map map)static List[]keysAndCorrespondingValues(Map map)The nth key corresponds to the nth valuestatic ObjectrandomElement(List list)static CollectionremoveDuplicates(Collection original)Brute force, for when HashSet and TreeSet won't work (e.g.static voidremoveKeys(Collection keys, Map map)static voidresize(List list, int newSize)static Listreverse(List list)static SortedSetreverseSortedSet(int[] ints)static Collectionselect(Collection collection, Block block)The Smalltalk #select method.static voidsetIfNull(int i, List list, String value)static Collectionstretch(Collection source, Collection destination, int destinationSize)Data is evenly discarded or duplicated to attain the new size
-
-
-
Method Detail
-
combinations
public static List combinations(List original, int maxCombinationSize)
Returns a List of Lists: all combinations of the elements of the given List.- Parameters:
maxCombinationSize- combinations larger than this value are discarded
-
combinations
public static List combinations(List original, int maxCombinationSize, Object mandatoryItem)
Returns a List of Lists: all combinations of the elements of the given List.- Parameters:
maxCombinationSize- combinations larger than this value are discardedmandatoryItem- an item that all returned combinations must contain, or null to leave unspecified
-
combinations
public static List combinations(List original)
Returns a List of Lists: all combinations of the elements of the given List.
-
removeKeys
public static void removeKeys(Collection keys, Map map)
-
keysAndCorrespondingValues
public static List[] keysAndCorrespondingValues(Map map)
The nth key corresponds to the nth value
-
concatenate
public static Collection concatenate(Collection collections)
-
reverseSortedSet
public static SortedSet reverseSortedSet(int[] ints)
-
stretch
public static Collection stretch(Collection source, Collection destination, int destinationSize)
Data is evenly discarded or duplicated to attain the new size
-
ifNotIn
public static Object ifNotIn(Object o, Collection c, Object alternative)
-
resize
public static void resize(List list, int newSize)
-
removeDuplicates
public static Collection removeDuplicates(Collection original)
Brute force, for when HashSet and TreeSet won't work (e.g. #hashCode implementation isn't appropriate). The original Collection is not modified.
-
addIfNotNull
public static void addIfNotNull(Object item, Collection collection)
-
filterByClass
public static Collection filterByClass(Collection collection, Class c)
Modifies and returns the collection.
-
collect
public static Collection collect(Collection collection, Block block)
The Smalltalk #collect method.
-
select
public static Collection select(Collection collection, Block block)
The Smalltalk #select method.
-
-