/** * Clones this object. * * @return clone of this object */ public PairOfFloatInt clone() { return new PairOfFloatInt(this.leftElement, this.rightElement); }
/** * Checks two pairs for equality. * * @param obj object for comparison * @return <code>true</code> if <code>obj</code> is equal to this object, <code>false</code> * otherwise */ public boolean equals(Object obj) { PairOfFloatInt pair = (PairOfFloatInt) obj; return leftElement == pair.getLeftElement() && rightElement == pair.getRightElement(); }
/** * Creates a pair. * * @param left the left element * @param right the right element */ public PairOfFloatInt(float left, int right) { set(left, right); }
public static PairOfFloatInt of(float left, int right) { return new PairOfFloatInt(left, right); }
/** * Defines a natural sort order for pairs. Pairs are sorted first by the left element, and then by * the right element. * * @return a value less than zero, a value greater than zero, or zero if this pair should be * sorted before, sorted after, or is equal to <code>obj</code>. */ public int compareTo(PairOfFloatInt pair) { float pl = pair.getLeftElement(); int pr = pair.getRightElement(); if (leftElement == pl) { if (rightElement < pr) return -1; if (rightElement > pr) return 1; return 0; } if (leftElement < pl) return -1; return 1; }
public List<PairOfFloatInt> getTranslationsWithProbsAsList(float probThreshold){ List<PairOfFloatInt> l = new ArrayList<PairOfFloatInt>(); if (_useBinSearch) { for(int i=0; i < _data.length; i++){ if (_data[i] > probThreshold) { l.add(new PairOfFloatInt(_data[i],_indices[i])); } } }else{ for (int i=0; i < _data.length; i++) { if (_data[i] > probThreshold) { l.add(new PairOfFloatInt(_data[i],i)); } } } return l; }
public PriorityQueue<PairOfFloatInt> getTranslationsWithProbs(float probThreshold){ PriorityQueue<PairOfFloatInt> q = new PriorityQueue<PairOfFloatInt>(_data.length, Collections.reverseOrder()); if (_useBinSearch) { for (int i=0; i < _data.length; i++) { if (_data[i] > probThreshold) { q.add(new PairOfFloatInt(_data[i],_indices[i])); } } }else{ for (int i=0; i < _data.length; i++) { if (_data[i] > probThreshold) { q.add(new PairOfFloatInt(_data[i],i)); } } } return q; }