public class ContainerUtil
extends java.lang.Object
| Constructor and Description |
|---|
ContainerUtil() |
| Modifier and Type | Method and Description |
|---|---|
static <A> void |
add(java.util.Collection<A> c,
A a)
null safe add
|
static <A> void |
addAll(java.util.Collection<A> c,
A[] a)
appends all strings of an array to
this |
static <A> java.util.Collection<A> |
addAll(java.util.Collection<A> c1,
java.util.Collection<A> c2)
null safe addAll
|
static <A> void |
appendUnique(java.util.Collection<A> c,
A a)
AppendUnique - append an object but ignore multiple entries
|
static <A> java.util.Collection<A> |
appendUnique(java.util.Collection<A> c,
java.util.Collection<A> a)
AppendUnique - append an object but ignore multiple entries
|
static int |
compare(java.lang.Comparable c0,
java.lang.Comparable c1)
static implementation of compare for any comparable object that gracefully handles null
null is always the smallest |
static <A> boolean |
containsAll(java.util.Collection<A> c,
java.util.Collection<A> others)
null safe helper
|
static <A> boolean |
containsAny(java.util.Collection<A> c,
java.util.Collection<A> others)
checks whether at least one of a given vector of strings is contained in
this |
static <A> void |
ensureSize(int size,
java.util.Collection<A> coll)
ensure that a collection has at least size elements and fill any newly created entries with nulls
|
static boolean |
equals(java.lang.Object a,
java.lang.Object b)
return true if a equals b or both are null
|
static <A> A |
get(java.util.List<A> l,
int i) |
static <A,B> ListMap<B,A> |
getInvertedListMap(java.util.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,B> VectorMap<B,A> |
getInvertedMap(java.util.Map<A,B> m)
Deprecated.
|
static <A> java.util.Collection<A> |
getKeyArray(java.util.Map<A,?> m) |
static <A> java.util.List<A> |
getKeyList(java.util.Map<A,?> m) |
static <A> java.util.Vector<A> |
getKeyVector(java.util.Map<A,?> m)
Deprecated.
|
static <a> IMatches |
getMatch(java.util.Collection<? extends IMatches> c,
a obj,
int iSkip)
return a matching element from a collection of IMatches
|
static <A> A |
getMatch(IMatches match,
java.util.Collection<A> c,
int iSkip)
return a matching element from a collection of IMatches
|
static <A> java.util.Vector<IMatches> |
getMatches(java.util.Collection<? extends IMatches> c,
A obj)
return a matching element from a collection of IMatches
|
static <A> java.util.Vector<A> |
getMatches(IMatches m,
java.util.Collection<A> c)
return a matching element from a collection
|
static <A> java.util.List<IMatches> |
getMatchesList(java.util.Collection<? extends IMatches> c,
A obj)
return a matching element from a collection of IMatches
|
static <A> java.util.List<A> |
getMatchesList(IMatches m,
java.util.Collection<A> c)
return a matching element from a collection
|
static java.util.Collection<?> |
getNonEmpty(java.util.Collection<?> c)
return null if c==null or c.isEmpty=true used to zapp empty collections
|
static java.util.Map<?,?> |
getNonEmpty(java.util.Map<?,?> c)
return null if c==null or c.isEmpty=true used to zapp empty collections
|
static java.util.Collection<?> |
getNonEmptyCollection(java.util.Collection<? extends java.util.Collection<?>> c)
return null if c==null or c.isEmpty=true or c contains an empty collection used to zapp empty collections
|
static <A> java.util.List<A> |
getOverlapping(java.util.Collection<A> c,
java.util.Collection<A> others)
vector of strings that is contained in
this |
static <A> int |
index(java.util.List<A> l,
int i) |
static boolean |
isEmpty(java.util.Collection<?> c) |
static boolean |
isEmpty(java.util.Map<?,?> c) |
static boolean |
matches(IMatches a,
java.lang.Object b)
return true if a matches b or both are null
|
static boolean |
matchesExisting(IMatches a,
java.lang.Object b)
return true if a matches b or one of a or b is null
|
static <A> A |
remove(java.util.List<A> l,
int i)
remove but also implementing the usual neg number syntax
|
static int |
size(java.util.Collection<?> c) |
static int |
size(java.util.Map<?,?> c) |
static <A> java.util.List<A> |
toArrayList(A[] array)
create an ArrayList from an Array, skipping null elements
|
static <A,B> java.util.List<B> |
toArrayList(java.util.Map<A,B> m)
create a Vector copy of entry values from a map
|
static <A extends java.lang.Comparable<? super A>,B> |
toArrayList(java.util.Map<A,B> m,
boolean sortByKey)
create a Vector of entry values from a map
|
static <A> java.util.Set<A> |
toHashSet(A[] l)
create a HashSet from an Array
|
static <A> java.util.Set<A> |
toHashSet(java.util.Enumeration<A> enumeration)
create a HashSet from an enumeration
|
static <A> java.util.Set<A> |
toHashSet(java.util.List<A> list)
create a HashSet from a List (Vector...)
|
static <A,B> java.util.Vector<B> |
toValueVector(java.util.Map<A,B> m)
create a Vector copy of entry values from a map
|
static <a extends java.lang.Comparable<? super a>,b> |
toValueVector(java.util.Map<a,b> m,
boolean sortByKey)
create a Vector of entry values from a map
|
static <A> java.util.Vector<A> |
toVector(A[] array)
create a Vector from an Array, skipping null elements
|
static <A> java.util.Collection<A> |
unify(java.util.Collection<A> c)
unify a collection while retaining the initial order (if the input collection is ordered)
|
static <A extends IMatches> |
unifyMatches(java.util.Collection<A> c)
unify a collection while retaining the initial order (if the input collection is ordered)
|
public static <A> java.util.Set<A> toHashSet(java.util.Enumeration<A> enumeration)
A - the data type of the setsenumeration - the enumerationpublic static java.util.Collection<?> getNonEmpty(java.util.Collection<?> c)
c - the Collection to testpublic static java.util.Map<?,?> getNonEmpty(java.util.Map<?,?> c)
c - the Collection to testpublic static java.util.Collection<?> getNonEmptyCollection(java.util.Collection<? extends java.util.Collection<?>> c)
c - the Collection to testpublic static <A> java.util.Set<A> toHashSet(java.util.List<A> list)
A - the data type of the setslist - the listpublic static <A> java.util.Set<A> toHashSet(A[] l)
A - datatypel - the arraypublic static <A> java.util.Vector<A> toVector(A[] array)
public static <A> java.util.List<A> toArrayList(A[] array)
public static <A> java.util.Collection<A> addAll(java.util.Collection<A> c1,
java.util.Collection<A> c2)
A - typec1 - first collectionc2 - second collectionpublic static <A> boolean containsAny(java.util.Collection<A> c,
java.util.Collection<A> others)
thisothers - the VSTring of values to testthispublic static <A> boolean containsAll(java.util.Collection<A> c,
java.util.Collection<A> others)
A - c - others - public static <A> java.util.List<A> getOverlapping(java.util.Collection<A> c,
java.util.Collection<A> others)
thisothers - the VString of values to testthispublic static <A> void addAll(java.util.Collection<A> c,
A[] a)
thisstrings - the array of strings to append to thispublic static <A> void add(java.util.Collection<A> c,
A a)
strings - the array of strings to append to thispublic static <a> IMatches getMatch(java.util.Collection<? extends IMatches> c, a obj, int iSkip)
a - the data typec - the collection to searchobj - the search key for matchesiSkip - which one to grab, may be negative in which case we count -1=last, -2=second last...IMatchespublic static <A> A getMatch(IMatches match, java.util.Collection<A> c, int iSkip)
public static <A> java.util.Vector<IMatches> getMatches(java.util.Collection<? extends IMatches> c, A obj)
A - the data typec - the collection to searchobj - the search key for matchespublic static <A> java.util.List<IMatches> getMatchesList(java.util.Collection<? extends IMatches> c, A obj)
A - the data typec - the collection to searchobj - the search key for matchespublic static <A> java.util.Vector<A> getMatches(IMatches m, java.util.Collection<A> c)
A - the data typec - the collection to searchobj - the matchespublic static <A> java.util.List<A> getMatchesList(IMatches m, java.util.Collection<A> c)
A - the data typec - the collection to searchobj - the matchespublic static <a extends java.lang.Comparable<? super a>,b> java.util.Vector<b> toValueVector(java.util.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 extends java.lang.Comparable<? super A>,B> java.util.List<B> toArrayList(java.util.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> java.util.Vector<B> toValueVector(java.util.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> java.util.List<B> toArrayList(java.util.Map<A,B> m)
A - data type of the map keyB - data type of the map valuem - the map to dump to an array@Deprecated public static <A,B> VectorMap<B,A> getInvertedMap(java.util.Map<A,B> m)
A - data type of the map keyB - data type of the map valuem - the map to invertpublic static <A> void appendUnique(java.util.Collection<A> c,
A a)
a - the A to append, if null nothing is addedpublic static <A> java.util.Collection<A> appendUnique(java.util.Collection<A> c,
java.util.Collection<A> a)
a - the A to append, if null nothing is addedpublic static <A> int index(java.util.List<A> l,
int i)
l - i - public static <A> A get(java.util.List<A> l,
int i)
l - i - public static <A> A remove(java.util.List<A> l,
int i)
index - if 0, or positive count from front, else if negative from backVector.remove(int)public static <A,B> ListMap<B,A> getInvertedListMap(java.util.Map<A,B> m)
A - data type of the map keyB - data type of the map valuem - the map to invert@Deprecated public static <A> java.util.Vector<A> getKeyVector(java.util.Map<A,?> m)
A - data type of the map keym - the map to dump to an arraypublic static boolean equals(java.lang.Object a,
java.lang.Object b)
a - Object to compareb - Object to comparepublic static boolean matches(IMatches a, java.lang.Object b)
a - Object to compareb - Object to comparepublic static boolean matchesExisting(IMatches a, java.lang.Object b)
a - Object to compareb - Object to comparepublic static int compare(java.lang.Comparable c0,
java.lang.Comparable c1)
c0 - c1 - public static <A> void ensureSize(int size,
java.util.Collection<A> coll)
A - anything - needed for the castsize - coll - public static <A> java.util.Collection<A> unify(java.util.Collection<A> c)
A - the data type of the collectionc - the collection to unifypublic static <A extends IMatches> java.util.Collection<A> unifyMatches(java.util.Collection<A> c)
A - the data type of the collectionc - the collection to unifypublic static int size(java.util.Collection<?> c)
c - the collection to checkpublic static int size(java.util.Map<?,?> c)
c - the collection to checkpublic static boolean isEmpty(java.util.Collection<?> c)
c - public static boolean isEmpty(java.util.Map<?,?> c)
c - public static <A> java.util.Collection<A> getKeyArray(java.util.Map<A,?> m)
public static <A> java.util.List<A> getKeyList(java.util.Map<A,?> m)