Java Utililty Methods Vector

List of utility methods to do Vector

Description

The list of methods to do Vector are organized into topic(s).

Method

Vectorclonevector(Vector vec)
Clones vector vec without cloning the components of the vector
Vector result = new Vector();
for (int i = 0; i < vec.size(); i++)
    result.add(vec.elementAt(i));
return result;
StringcombineWithQuotes(Vector commands, int startAt)
combine With Quotes
final StringBuffer Combined = new StringBuffer("");
if (commands != null)
    for (int commandIndex = startAt; commandIndex < commands.size(); commandIndex++) {
        String s = (String) commands.elementAt(commandIndex);
        if (s.indexOf(' ') >= 0)
            s = "\"" + s + "\"";
        Combined.append(s + " ");
return Combined.toString().trim();
booleanContains(Vector V, int[] elt)
Contains
if (V == null || V.size() < 1)
    return false;
if (elt == null || elt.length != 2)
    return true;
for (int i = 0; i < V.size(); i++) {
    int[] R = V.elementAt(i);
    if (R[0] == elt[0] && R[1] == elt[1])
        return true;
...
VectorcopyVector(Vector V)
copy Vector
final Vector V2 = new Vector();
for (int v = 0; v < V.size(); v++) {
    final Object h = V.elementAt(v);
    if (h instanceof Vector)
        V2.addElement(copyVector((Vector) h));
    else
        V2.addElement(h);
return V2;
voiddeleteLast(Vector list)
delete Last
int lastIndex = list.size() - 1;
list.remove(lastIndex);
VectorenumerationToVector(Enumeration pEnumeration_)
Convert an enumeration to a vector.
Vector vRetVal = new Vector();
while (pEnumeration_.hasMoreElements()) {
    Object pObject = pEnumeration_.nextElement();
    vRetVal.addElement(pObject);
return vRetVal;
StringgetCommaListFromVector(Vector sourceVector)
get Comma List From Vector
StringBuffer strBuf = new StringBuffer();
for (int i = 0; i < sourceVector.size(); i++) {
    strBuf.append((i > 0 ? ", " : "") + sourceVector.elementAt(i));
return strBuf.toString();
int[][]getNonNullVectors(int[][] usageM)
get Non Null Vectors
List<int[]> nonNullVectors = new ArrayList<int[]>();
for (int[] v : usageM) {
    boolean isNull = true;
    for (int i = 0; i < v.length; i++)
        if (v[i] > 0)
            isNull = false;
    if (!isNull)
        nonNullVectors.add(v);
...
booleanhasDuplicates(Vector v)
has Duplicates
int i = 0;
int j = 0;
boolean duplicates = false;
for (i = 0; i < v.size() - 1; i++) {
    for (j = (i + 1); j < v.size(); j++) {
        if (v.elementAt(i).toString().equalsIgnoreCase(v.elementAt(j).toString())) {
            duplicates = true;
return duplicates;
booleanisContained(Object obj, Vector vect)
Check if object is contained in vector
if (obj == null || vect == null) {
    return false;
return vect.contains(obj);