public class ContainerUtil extends Object
| Constructor and Description |
|---|
ContainerUtil() |
| Modifier and Type | Method and Description |
|---|---|
static <a> Collection<a> |
addAll(Collection<a> c1,
Collection<a> c2)
null safe addAll
|
static int |
compare(Comparable c0,
Comparable c1)
static implementation of compare for any comparable object that gracefully handles null
null is always the smallest |
static <a> void |
ensureSize(int size,
Collection<a> coll)
ensure that a collection has at least size elements and fill any newly created entries with nulls
|
static boolean |
equals(Object a,
Object b)
return true if a equals b or both are null
|
static <a,b> VectorMap<b,a> |
getInvertedMap(Map<a,b> m)
create an inverted map with keys and values swapped.
The new values are vectors since a map may have identical values for different keys |
static <a> Vector<a> |
getKeyVector(Map<a,?> m)
create a Vector of key values from a map
|
static <a> IMatches |
getMatch(Collection<? extends IMatches> c,
a obj,
int iSkip)
return a matching element from a collection of IMatches
|
static <a> Vector<IMatches> |
getMatches(Collection<? extends IMatches> c,
a obj)
return a matching element from a collection of IMatches
|
static boolean |
matches(IMatches a,
Object b)
return true if a matches b or both are null
|
static boolean |
matchesExisting(IMatches a,
Object b)
return true if a matches b or one of a or b is null
|
static <a> Set<a> |
toHashSet(a[] l)
create a HashSet from an Array
|
static <a> Set<a> |
toHashSet(Enumeration<a> enumeration)
create a HashSet from an enumeration
|
static <a> Set<a> |
toHashSet(List<a> list)
create a HashSet from a List (Vector...)
|
static <a,b> Vector<b> |
toValueVector(Map<a,b> m)
create a Vector copy of entry values from a map
|
static <a extends Comparable<? super a>,b> |
toValueVector(Map<a,b> m,
boolean sortByKey)
create a Vector of entry values from a map
|
static <a> Vector<a> |
toVector(a[] array)
create a Vector from an Array, skipping null elements
|
static <a> Collection<a> |
unify(Collection<a> c)
unify a collection while retaining the initial order (if the input collection is ordered)
|
public static <a> Set<a> toHashSet(Enumeration<a> enumeration)
a - the data type of the setsenumeration - the enumerationpublic static <a> Set<a> toHashSet(List<a> list)
a - the data type of the setslist - the listpublic static <a> Set<a> toHashSet(a[] l)
a - datatypel - the arraypublic static <a> Vector<a> toVector(a[] array)
public static <a> Collection<a> addAll(Collection<a> c1, Collection<a> c2)
a - typec1 - first collectionc2 - second collectionpublic static <a> IMatches getMatch(Collection<? extends IMatches> c, a obj, int iSkip)
public static <a> Vector<IMatches> getMatches(Collection<? extends IMatches> c, a obj)
a - the data typec - the collection to searchobj - the search key for matchespublic static <a extends Comparable<? super a>,b> Vector<b> toValueVector(Map<a,b> m, boolean sortByKey)
a - type of the map keyb - type of the map entrym - the map to dump to an arraysortByKey - , if true, sort the entries by keypublic static <a,b> Vector<b> toValueVector(Map<a,b> m)
a - data type of the map keyb - data type of the map valuem - the map to dump to an arraypublic static <a,b> VectorMap<b,a> getInvertedMap(Map<a,b> m)
a - data type of the map keyb - data type of the map valuem - the map to invertpublic static <a> Vector<a> getKeyVector(Map<a,?> m)
a - data type of the map keym - the map to dump to an arraypublic static boolean equals(Object a, Object b)
a - Object to compareb - Object to comparepublic static boolean matches(IMatches a, Object b)
a - Object to compareb - Object to comparepublic static boolean matchesExisting(IMatches a, Object b)
a - Object to compareb - Object to comparepublic static int compare(Comparable c0, Comparable c1)
c0 - c1 - public static <a> void ensureSize(int size,
Collection<a> coll)
a - anything - needed for the castsize - coll - public static <a> Collection<a> unify(Collection<a> c)
a - the data type of the collectionc - the collection to unifyCopyright © 2015. All rights reserved.