/** * Clones this object. * * @return clone of this object */ public PairOfIntLong clone() { return new PairOfIntLong(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) { PairOfIntLong pair = (PairOfIntLong) obj; return leftElement == pair.getLeftElement() && rightElement == pair.getRightElement(); }
/** * Creates a pair. * * @param left the left element * @param right the right element */ public PairOfIntLong(int left, long right) { set(left, right); }
public int compare(PairOfIntLong e1, PairOfIntLong e2) { if (e1.getLeftElement() > e2.getLeftElement()) { return 1; } if (e1.getLeftElement() < e2.getLeftElement()) { return -1; } throw new RuntimeException("Event observed twice!"); } };
public int compare(PairOfIntLong e1, PairOfIntLong e2) { if (e1.getLeftElement() > e2.getLeftElement()) { return -1; } if (e1.getLeftElement() < e2.getLeftElement()) { return 1; } throw new RuntimeException("Event observed twice!"); } };
public int compare(PairOfIntLong e1, PairOfIntLong e2) { if (e1.getRightElement() > e2.getRightElement()) { return 1; } if (e1.getRightElement() < e2.getRightElement()) { return -1; } if (e1.getLeftElement() == e2.getLeftElement()) { throw new RuntimeException("Event observed twice!"); } return e1.getLeftElement() < e2.getLeftElement() ? -1 : 1; } };
public static PairOfIntLong of(int left, long right) { return new PairOfIntLong(left, right); }
public int compare(PairOfIntLong e1, PairOfIntLong e2) { if (e1.getLeftElement() > e2.getLeftElement()) { return -1; } if (e1.getLeftElement() < e2.getLeftElement()) { return 1; } throw new RuntimeException("Event observed twice!"); } };
@Override public PairOfIntLong next() { if (!hasNext()) { return null; } Int2LongMap.Entry entry = iter.next(); pair.set(entry.getIntKey(), entry.getLongValue()); return pair; }
public int compare(PairOfIntLong e1, PairOfIntLong e2) { if (e1.getRightElement() > e2.getRightElement()) { return -1; } if (e1.getRightElement() < e2.getRightElement()) { return 1; } if (e1.getLeftElement() == e2.getLeftElement()) { throw new RuntimeException("Event observed twice!"); } return e1.getLeftElement() < e2.getLeftElement() ? -1 : 1; } };
/** * Iterator returns the same object every time, just with a different payload. */ public Iterator<PairOfIntLong> iterator() { return new Iterator<PairOfIntLong>() { private Iterator<MapIL.Entry> iter = Int2LongFrequencyDistributionEntry.this.counts .entrySet().iterator(); private final PairOfIntLong pair = new PairOfIntLong(); @Override public boolean hasNext() { return iter.hasNext(); } @Override public PairOfIntLong next() { if (!hasNext()) { return null; } MapIL.Entry entry = iter.next(); pair.set(entry.getKey(), entry.getValue()); return pair; } @Override public void remove() { throw new UnsupportedOperationException(); } }; }
public int compare(PairOfIntLong e1, PairOfIntLong e2) { if (e1.getLeftElement() > e2.getLeftElement()) { return 1; } if (e1.getLeftElement() < e2.getLeftElement()) { return -1; } throw new RuntimeException("Event observed twice!"); } };
@Override public PairOfIntLong next() { if (!hasNext()) { return null; } MapIL.Entry entry = iter.next(); pair.set(entry.getKey(), entry.getValue()); return pair; }
public int compare(PairOfIntLong e1, PairOfIntLong e2) { if (e1.getRightElement() > e2.getRightElement()) { return 1; } if (e1.getRightElement() < e2.getRightElement()) { return -1; } if (e1.getLeftElement() == e2.getLeftElement()) { throw new RuntimeException("Event observed twice!"); } return e1.getLeftElement() < e2.getLeftElement() ? -1 : 1; } };
private List<PairOfIntLong> getEntriesSorted(Comparator<PairOfIntLong> comparator) { List<PairOfIntLong> list = Lists.newArrayList(); for (MapIL.Entry e : counts.entrySet()) { list.add(new PairOfIntLong(e.getKey(), e.getValue())); } Collections.sort(list, comparator); return list; }
public int compare(PairOfIntLong e1, PairOfIntLong e2) { if (e1.getRightElement() > e2.getRightElement()) { return -1; } if (e1.getRightElement() < e2.getRightElement()) { return 1; } if (e1.getLeftElement() == e2.getLeftElement()) { throw new RuntimeException("Event observed twice!"); } return e1.getLeftElement() < e2.getLeftElement() ? -1 : 1; } };
/** * Iterator returns the same object every time, just with a different payload. */ public Iterator<PairOfIntLong> iterator() { return new Iterator<PairOfIntLong>() { private Iterator<Int2LongMap.Entry> iter = Int2LongFrequencyDistributionFastutil.this.counts .int2LongEntrySet().iterator(); private final PairOfIntLong pair = new PairOfIntLong(); @Override public boolean hasNext() { return iter.hasNext(); } @Override public PairOfIntLong next() { if (!hasNext()) { return null; } Int2LongMap.Entry entry = iter.next(); pair.set(entry.getIntKey(), entry.getLongValue()); return pair; } @Override public void remove() { throw new UnsupportedOperationException(); } }; }
/** * 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(PairOfIntLong pair) { int pl = pair.getLeftElement(); long 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; }
private List<PairOfIntLong> getEntriesSorted(Comparator<PairOfIntLong> comparator) { List<PairOfIntLong> list = Lists.newArrayList(); for (Int2LongMap.Entry e : counts.int2LongEntrySet()) { list.add(new PairOfIntLong(e.getIntKey(), e.getLongValue())); } Collections.sort(list, comparator); return list; }