Example usage for java.util Vector get

List of usage examples for java.util Vector get

Introduction

In this page you can find the example usage for java.util Vector get.

Prototype

public synchronized E get(int index) 

Source Link

Document

Returns the element at the specified position in this Vector.

Usage

From source file:Main.java

public static Hashtable<Integer, Set<Integer>> getNodeMembership(Hashtable<Integer, Set<Integer>> nIDComVH,
        final Vector<Set<Integer>> cmtyVV) {
    for (int i = 0; i < cmtyVV.size(); i++) {
        int CID = i;
        for (Integer NID : cmtyVV.get(i)) {
            if (nIDComVH.containsKey(NID)) {
                Set<Integer> x = nIDComVH.get(NID);
                x.add(CID);//from   w  w w . j av  a2 s .c o m
            } else {
                Set<Integer> x = new HashSet<Integer>();
                x.add(CID);
                nIDComVH.put(NID, x);
            }

        }
    }
    return nIDComVH;
}

From source file:Main.java

/**
 * /* w  ww.  j a v  a  2s .  co  m*/
 * @param el
 * @return depth of an XML node tree
 */
public static int getDepth(Element el) {
    int depth = 1;
    if (el.getAttributes().getLength() > 0)
        depth = 2;

    int max = 0;
    Vector<Element> childElements = childElements(el);
    for (int i = 0; i < childElements.size(); i++) {
        int childDepth = getDepth(childElements.get(i));
        if (childDepth > max)
            max = childDepth;
    }

    return depth + max;
}

From source file:Main.java

/**
 * @param el/*from  w w w .j a v a 2  s  .c  o m*/
 * @return the number of element and attribute nodes in an XML tree
 */
public static int nodeValueCount(Element el) {
    int count = el.getAttributes().getLength(); //  attributes of this node

    // text value of this node
    String text = getText(el);
    if ((text != null) && (!text.equals("")))
        count++;

    // contributions from child elements
    Vector<Element> childElements = childElements(el);
    for (int i = 0; i < childElements.size(); i++)
        count = count + nodeValueCount(childElements.get(i));

    return count;
}

From source file:corner.util.VectorUtils.java

/**
 * ??.//w w  w  .  jav  a2  s.  c  o m
 * 
 * @param list
 *            ??.
 * @return ???.
 * @TODO ????.
 */
public static <T> Vector<Double> sumList(List<Vector<T>> list) {
    Vector<Double> r = new Vector<Double>();
    if (list.size() == 0) {
        return r;
    }
    StringBuffer sb = new StringBuffer();

    int width = list.get(0).size();
    for (int i = 0; i < width; i++) {
        for (Vector<T> v : list) {
            sb.append(v.get(i));
            sb.append("+");
        }
        sb.append("0");

        r.add(i, expr(sb.toString()));

        sb.setLength(0);
    }

    return r;
}

From source file:Main.java

public static Hashtable<Integer, Vector<Integer>> getNodeMembership(final Vector<Vector<Integer>> CmtyVV) {
    Hashtable<Integer, Vector<Integer>> NIDComVH = new Hashtable<Integer, Vector<Integer>>();
    for (int CID = 0; CID < CmtyVV.size(); CID++) {
        for (Integer NID : CmtyVV.get(CID)) {
            if (!NIDComVH.contains(NID)) {
                Vector<Integer> v = new Vector<Integer>();
                v.add(CID);//w w  w  .j av a2  s  .c  om
                NIDComVH.put(NID, v);
            } else {
                Vector<Integer> v = NIDComVH.get(NID);
                v.add(CID);
                NIDComVH.put(NID, v);
            }
        }
    }
    return NIDComVH;
}

From source file:Main.java

/**
 * dump bipartite community affiliation into a text file with node names
 * /*from w w w.  ja va2s . com*/
 * @param OutFNm
 * @param CmtyVV
 * @param NIDNmH
 */
static void dumpCmtyVV(final String OutFNm, Vector<Vector<Integer>> CmtyVV, Hashtable<Integer, String> NIDNmH) {
    PrintWriter f;
    try {
        f = new PrintWriter(OutFNm);

        for (int c = 0; c < CmtyVV.size(); c++) {
            for (int u = 0; u < CmtyVV.get(c).size(); u++) {
                if (NIDNmH.containsKey(CmtyVV.get(c).get(u))) {
                    f.printf("%s\t", NIDNmH.get(CmtyVV.get(c).get(u)));
                } else {
                    f.printf("%d\t", (int) CmtyVV.get(c).get(u));
                }
            }
            f.printf("\n");
        }
        f.close();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static String[] kommaList2Arr(String s, char sep) {
    if (s == null) {
        return null;
    }//  w  ww  .  j av a  2s .  c  o  m
    Vector v;
    if (s.length() > 0) {
        v = split(s, sep);
    } else {
        v = new Vector();
    }
    String[] aa = new String[v.size()];
    for (int ii = 0; ii < v.size(); ii++) {
        aa[ii] = (String) v.get(ii);
    }
    return aa;
}

From source file:Main.java

public static int[] kommaList2IntArr(String s, char sep) {
    if (s == null) {
        return null;
    }/*from   w  w w .  j  a  va 2  s .  c  o  m*/
    Vector v;
    if (s.length() > 0) {
        v = split(s, sep);
    } else {
        v = new Vector();
    }
    int[] aa = new int[v.size()];
    for (int ii = 0; ii < v.size(); ii++) {
        aa[ii] = string2int((String) v.get(ii), 0);
    }
    return aa;
}

From source file:it.acubelab.smaph.learn.GenerateModel.java

public static String getModelFileNameBaseEF(Integer[] ftrs, double wPos, double wNeg, double editDistance,
        double gamma, double C) {
    Vector<Integer> features = new Vector<Integer>(Arrays.asList(ftrs));
    Collections.sort(features);//w  ww .  ja  v a2s  .  c o m
    String filename = "models/model_";
    for (int f : features)
        filename += f + (f == features.get(features.size() - 1) ? "" : ",");
    filename += String.format("_%.5f_%.5f_%.3f_%.8f_%.8f", wPos, wNeg, editDistance, gamma, C);
    return filename;

}

From source file:it.acubelab.smaph.learn.GenerateModel.java

public static String getModelFileNameBaseEQF(Integer[] ftrs, double wPos, double wNeg) {
    Vector<Integer> features = new Vector<Integer>(Arrays.asList(ftrs));
    Collections.sort(features);/* w  w  w  . j  av a 2s . c  o m*/
    String filename = "models/EQ_model_";
    for (int f : features)
        filename += f + (f == features.get(features.size() - 1) ? "" : ",");
    filename += String.format("_%.5f_%.5f", wPos, wNeg);
    return filename;

}