Java Utililty Methods Vector

List of utility methods to do Vector

  1. HOME
  2. Java
  3. V
  4. Vector

Description

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

Method

Vector clonevector(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;
String combineWithQuotes(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();
boolean Contains(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;
...
Vector copyVector(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;
void deleteLast(Vector list)
delete Last
int lastIndex = list.size() - 1;
list.remove(lastIndex);
Vector enumerationToVector(Enumeration pEnumeration_)
Convert an enumeration to a vector.
Vector vRetVal = new Vector();
while (pEnumeration_.hasMoreElements()) {
 Object pObject = pEnumeration_.nextElement();
 vRetVal.addElement(pObject);
return vRetVal;
String getCommaListFromVector(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);
...
boolean hasDuplicates(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;
boolean isContained(Object obj, Vector vect)
Check if object is contained in vector
if (obj == null || vect == null) {
 return false;
return vect.contains(obj);


AltStyle によって変換されたページ (->オリジナル) /