public class VectorUtils
extends java.lang.Object
| Constructor and Description |
|---|
VectorUtils() |
| Modifier and Type | Method and Description |
|---|---|
static <E> java.util.Vector<E> |
difference(java.util.List<E> vectA,
java.util.List<E> vectB)
This method returns a Vector containing the set of objects
contained in vectA that are not contained in vectB.
|
static <E> java.util.Vector<E> |
duplicates(java.util.List<E> vector)
This method returns a Vector of items that appeared in the
vector parameter more than once.
|
static <E> boolean |
equalMembers(java.util.List<E> vectA,
java.util.List<E> vectB)
This method returns true if vectA and vectB contain the same
elements, in whatever order.
|
private static int |
findNextSep(java.lang.String input,
int startDex,
java.lang.String sepChars)
findNextSep() takes a string, a starting position, and a string of
characters to be considered field separators, and returns the
first index after startDex whose char is in sepChars.
|
static <E> java.util.Vector<E> |
intersection(java.util.List<E> vectA,
java.util.List<E> vectB)
This method returns a Vector containing the intersection of the
objects contained in vectA and vectB.
|
static void |
main(java.lang.String[] args) |
static <E> java.util.Vector<E> |
minus(java.util.List<E> vectA,
java.util.List<E> vectB)
This method returns a Vector containing the elements of vectA minus
the elements of vectB.
|
static <E> boolean |
overlaps(java.util.List<E> vectA,
java.util.List<E> vectB)
Returns true if vectA and vectB have any elements in
common.
|
static java.util.Vector |
stringVector(java.lang.String input,
java.lang.String sepChars)
This method takes a sepChars-separated string and converts it to
a vector of fields.
|
static <E> java.util.Vector<E> |
union(java.util.List<E> vectA,
java.util.List<E> vectB)
This method returns a Vector containing the union of the objects
contained in vectA and vectB.
|
static <E> void |
unionAdd(java.util.List<E> vect,
E obj)
This method adds obj to vect if and only if vect does not
already contain obj.
|
static java.lang.String |
vectorString(java.util.Collection vec)
This method returns a string containing all the elements in vec
concatenated together, comma separated.
|
static java.lang.String |
vectorString(java.util.Collection vec,
java.lang.String separator)
This method returns a string containing all the elements in vec
concatenated together, comma separated.
|
private static int |
vectSize(java.util.List x) |
public static <E> java.util.Vector<E> union(java.util.List<E> vectA,
java.util.List<E> vectB)
This method returns a Vector containing the union of the objects contained in vectA and vectB. The resulting Vector will not contain any duplicates, even if vectA or vectB themselves contain repeated items.
This method will always return a new, non-null Vector, even if vectA and/or vectB are null.
public static <E> void unionAdd(java.util.List<E> vect,
E obj)
This method adds obj to vect if and only if vect does not already contain obj.
public static <E> boolean overlaps(java.util.List<E> vectA,
java.util.List<E> vectB)
Returns true if vectA and vectB have any elements in common.
public static <E> java.util.Vector<E> intersection(java.util.List<E> vectA,
java.util.List<E> vectB)
This method returns a Vector containing the intersection of the objects contained in vectA and vectB.
This method will always return a new, non-null Vector, even if vectA and/or vectB are null.
public static <E> java.util.Vector<E> difference(java.util.List<E> vectA,
java.util.List<E> vectB)
This method returns a Vector containing the set of objects contained in vectA that are not contained in vectB.
NB: This method differs from minus(), which explicitly handles lists with duplicate members and returns an algebraic count of the non-duplicates. By contrast, difference() returns a Vector with no duplicates.
This method will always return a new, non-null Vector, even if vectA and/or vectB are null.
public static <E> boolean equalMembers(java.util.List<E> vectA,
java.util.List<E> vectB)
This method returns true if vectA and vectB contain the same elements, in whatever order.
public static <E> java.util.Vector<E> duplicates(java.util.List<E> vector)
This method returns a Vector of items that appeared in the vector parameter more than once.
If no duplicates are found or if vector is null, this method returns null.
public static <E> java.util.Vector<E> minus(java.util.List<E> vectA,
java.util.List<E> vectB)
This method returns a Vector containing the elements of vectA minus the elements of vectB.
NB: This method is not a synonym for difference(). With minus(), if vectA has an element in the Vector 5 times and vectB has it 3 times, the result will have it two times. difference() always returns a Vector without duplicates
This method will always return a new, non-null Vector, even if vectA and/or vectB are null.
public static java.lang.String vectorString(java.util.Collection vec)
This method returns a string containing all the elements in vec concatenated together, comma separated.
public static java.lang.String vectorString(java.util.Collection vec,
java.lang.String separator)
This method returns a string containing all the elements in vec concatenated together, comma separated.
public static java.util.Vector stringVector(java.lang.String input,
java.lang.String sepChars)
This method takes a sepChars-separated string and converts it to a vector of fields. i.e., "gomod,jonabbey" -> a vector whose elements are "gomod" and "jonabbey".
NOTE: this method will omit 'degenerate' fields from the output vector. That is, if input is "gomod,,, jonabbey" and sepChars is ", ", then the result vector will still only have "gomod" and "jonabbey" as elements, even though one might wish to explicitly know about the blanks between commas. This method is intended mostly for creating email list vectors, rather than general file-parsing vectors.
input - the sepChars-separated string to test.sepChars - a string containing a list of characters which
may occur as field separators. Any two fields in the input may
be separated by one or many of the characters present in sepChars.private static int findNextSep(java.lang.String input,
int startDex,
java.lang.String sepChars)
findNextSep() takes a string, a starting position, and a string of characters to be considered field separators, and returns the first index after startDex whose char is in sepChars.
If there are no chars in sepChars past startdex in input, findNextSep() returns -1.
private static int vectSize(java.util.List x)
public static void main(java.lang.String[] args)