@SuppressWarnings("serial") @Override public Result<T> next() { final DoubleObjectEntry<T> entry = (desc) ? treeMap.pollLastEntry() : treeMap.pollFirstEntry(); return new Result<T>() { public T item() { return entry.getValue(); } public double score() { return entry.getKey(); } }; }
@Override public boolean hasNext() { return treeMap.isEmpty(); }