@Override protected boolean lessThan(Object obj0, Object obj1) { // If equal scores, break tie by int descending. if (((PairOfIntFloat) obj0).getValue() == ((PairOfIntFloat) obj1).getValue()) { return ((PairOfIntFloat) obj0).getKey() < ((PairOfIntFloat) obj1).getKey() ? true : false; } return (((PairOfIntFloat) obj0).getValue() < ((PairOfIntFloat) obj1).getValue()) ? true : false; } }
@Override public void write(DataOutput out) throws IOException { out.writeInt(maxElements); int sz = size(); out.writeInt(sz); // Note: serialization is destructive! PairOfIntFloat pair; for (int i = 0; i < sz; i++) { pair = queue.pop(); out.writeInt(pair.getKey()); out.writeFloat(pair.getValue()); } } }