PositionalIterator<T> () { return new PositionalIterator<T>() { private QueueEntry<T> cursor = TOMB; private long count; @Override public boolean hasNext() { return cursor.next != TOMB; } @Override public T next() { cursor = cursor.next; count++; return cursor.t; } @Override public void remove() { if (cursor == TOMB) throw new NoSuchElementException(); HashSetQueue.this.remove(cursor.t); } @Override public @NotNull IteratorPosition<T> position() { return new MyIteratorPosition<>(cursor, count, TOMB); } }; }