Example usage for java.util Vector.Element equals

List of usage examples for java.util Vector.Element equals

Introduction

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

Prototype

public synchronized boolean equals(Object o) 

Source Link

Document

Compares the specified Object with this Vector for equality.

Usage

From source file:finderbots.recommenders.hadoop.WriteToSolrJob.java

private String getOrderedItems(Vector v, BiMap<String, String> elementIndex) {
    String doc = new String("");
    //sort the vector by element weight
    class VectorElementComparator implements Comparator<Vector.Element> {

        @Override/* w  w w.j  ava2 s.  c  o  m*/
        public int compare(Vector.Element o1, Vector.Element o2) {
            return (o1.get() > o2.get() ? -1 : (o1.equals(o2) ? 0 : 1));
        }
    }

    ArrayList<Vector.Element> vel = new ArrayList<Vector.Element>();
    for (Vector.Element ve : v.nonZeroes())
        vel.add(ve);
    Collections.sort(vel, new VectorElementComparator());
    for (Vector.Element ve : vel) {
        int i = ve.index();
        String s = String.valueOf(i);
        String exID = elementIndex.inverse().get(s);
        String intID = elementIndex.get(s);
        doc += exID + " ";
    }
    return doc;
}