List of usage examples for com.google.common.collect AbstractLinkedIterator AbstractLinkedIterator
protected AbstractLinkedIterator(@Nullable T paramT)
From source file:org.learningu.scheduling.util.bst.BstMap.java
private Set<Entry<K, V>> createEntrySet() { return new AbstractSet<Entry<K, V>>() { @Override/*from ww w . j a va 2 s . c om*/ public Iterator<Entry<K, V>> iterator() { final BstInOrderPath<TreapNode<K, V>> startingPath = BstRangeOps.furthestPath(range, LEFT, pathFactory(), root); final Iterator<BstInOrderPath<TreapNode<K, V>>> pathIterator = new AbstractLinkedIterator<BstInOrderPath<TreapNode<K, V>>>( startingPath) { @Override protected BstInOrderPath<TreapNode<K, V>> computeNext( BstInOrderPath<TreapNode<K, V>> previous) { if (!previous.hasNext(RIGHT)) { return null; } BstInOrderPath<TreapNode<K, V>> next = previous.next(RIGHT); return range.contains(next.getTip().getKey()) ? next : null; } }; return new Iterator<Entry<K, V>>() { K toRemove = null; @Override public boolean hasNext() { return pathIterator.hasNext(); } @Override public Entry<K, V> next() { BstInOrderPath<TreapNode<K, V>> path = pathIterator.next(); TreapNode<K, V> tip = path.getTip(); toRemove = tip.getKey(); return Maps.immutableEntry(tip.getKey(), tip.getValue()); } @Override public void remove() { checkState(toRemove != null); BstMap.this.remove(toRemove); toRemove = null; } }; } @Override public int size() { return BstMap.this.size(); } }; }