/** * Clones this object. * * @return clone of this object */ public PairOfIntLong clone() { return new PairOfIntLong(this.leftElement, this.rightElement); }
public static PairOfIntLong of(int left, long right) { return new PairOfIntLong(left, right); }
/** * 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(); } }; }
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; }
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; }
/** * 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(); } }; }