List of usage examples for java.util Vector elementAt
public synchronized E elementAt(int index)
From source file:Main.java
public static double norm(Vector<Double> l1, Vector<Double> l2) { assert (l1.size() == l2.size()); double ans = 0.; for (int i = 0; i < l1.size(); ++i) ans += (l1.elementAt(i) - l2.elementAt(i)) * (l1.elementAt(i) - l2.elementAt(i)); ans = Math.sqrt(ans);// w ww. j a v a 2 s. c om return ans; }
From source file:Main.java
public static Object[][] to2DArray(Vector<Vector> towDVector) { Object[][] towDArray = new Object[towDVector.size()][]; for (int i = 0; i < towDVector.size(); i++) { Vector row = (Vector) towDVector.elementAt(i); towDArray[i] = row.toArray();// w w w. ja v a 2 s .com } return towDArray; }
From source file:Main.java
/** * Method getHashMapFromVector./* www . j a v a 2s . c o m*/ * @param vector Vector * @return HashMap */ public static HashMap getHashMapFromVector(Vector vector) { HashMap hashMap = new HashMap(vector.size()); for (int i = 0; i < vector.size(); i++) { hashMap.put(vector.elementAt(i), vector.elementAt(i)); } return hashMap; }
From source file:Main.java
public static <K> K setElementAt(Vector<K> vec, int index, K value) { K retVal;/*from ww w . java 2 s. co m*/ if (vec.size() <= index) { vec.setSize(index + 10); retVal = null; } else retVal = vec.elementAt(index); vec.setElementAt(value, index); return retVal; }
From source file:Main.java
public static void copyIntoVector(Vector paramVector1, int paramInt, Vector paramVector2) { int i = paramInt; try {//from w w w . jav a2 s .c o m while (i < paramVector1.size()) { paramVector2.insertElementAt(paramVector1.elementAt(i), i - paramInt); i++; } return; } finally { } }
From source file:Main.java
/** * Method getHashtableFromVector./*from www .jav a 2 s.c om*/ * @param vector Vector * @return Hashtable */ public static Hashtable getHashtableFromVector(Vector vector) { Hashtable hashtable = new Hashtable(vector.size()); for (int i = 0; i < vector.size(); i++) { hashtable.put(vector.elementAt(i), vector.elementAt(i)); } return hashtable; }
From source file:Main.java
public static String getFieldName(Vector vtNameStack) { StringBuffer strFieldName = new StringBuffer(); for (int iIndex = 0; iIndex < vtNameStack.size(); iIndex++) { strFieldName.append('.'); strFieldName.append((String) vtNameStack.elementAt(iIndex)); }//from w w w . jav a2s .c o m if (strFieldName.length() > 0) strFieldName.delete(0, 1); return strFieldName.toString(); }
From source file:TreeViewBasedOnNode.java
private static void addNode(TreeItem parentItem, Node node) { TreeItem item = null;/*ww w . j a v a 2s. co m*/ if (parentItem == null) item = new TreeItem(tree, SWT.NONE); else item = new TreeItem(parentItem, SWT.NONE); item.setText(node.getName()); Vector subs = node.getSubCategories(); for (int i = 0; subs != null && i < subs.size(); i++) addNode(item, (Node) subs.elementAt(i)); }
From source file:Main.java
/** * @param first First Integer Vector to be merged * @param second Second Integer Vector to be merged * @return single merged int array of first and second *//*from w w w. j a v a2 s. co m*/ public static int[] mergeIntegerVectorsInArray(Vector<Integer> first, Vector<Integer> second) { int resultLength = first.size() + second.size(); int[] result = new int[resultLength]; int i = 0; for (; i < first.size(); ++i) { result[i] = first.elementAt(i); } for (; i < resultLength; ++i) { result[i] = second.elementAt(i - first.size()); } return result; }
From source file:Main.java
static public Element[] findAllDescendantElements(Node e, String qname) { Vector v = new Vector(); findAllDescendantElements(e, qname, v); Element array[] = new Element[v.size()]; for (int i = 0; i < array.length; ++i) { array[i] = (Element) v.elementAt(i); }/*from w ww . j a v a 2 s . c o m*/ return array; }