com.koloboke.collect
Interface Cursor

All Known Subinterfaces:
ByteByteCursor, ByteCharCursor, ByteCursor, ByteDoubleCursor, ByteFloatCursor, ByteIntCursor, ByteLongCursor, ByteObjCursor<V>, ByteShortCursor, CharByteCursor, CharCharCursor, CharCursor, CharDoubleCursor, CharFloatCursor, CharIntCursor, CharLongCursor, CharObjCursor<V>, CharShortCursor, DoubleByteCursor, DoubleCharCursor, DoubleCursor, DoubleDoubleCursor, DoubleFloatCursor, DoubleIntCursor, DoubleLongCursor, DoubleObjCursor<V>, DoubleShortCursor, FloatByteCursor, FloatCharCursor, FloatCursor, FloatDoubleCursor, FloatFloatCursor, FloatIntCursor, FloatLongCursor, FloatObjCursor<V>, FloatShortCursor, IntByteCursor, IntCharCursor, IntCursor, IntDoubleCursor, IntFloatCursor, IntIntCursor, IntLongCursor, IntObjCursor<V>, IntShortCursor, LongByteCursor, LongCharCursor, LongCursor, LongDoubleCursor, LongFloatCursor, LongIntCursor, LongLongCursor, LongObjCursor<V>, LongShortCursor, ObjByteCursor<K>, ObjCharCursor<K>, ObjCursor<E>, ObjDoubleCursor<K>, ObjFloatCursor<K>, ObjIntCursor<K>, ObjLongCursor<K>, ObjObjCursor<K,V>, ObjShortCursor<K>, ShortByteCursor, ShortCharCursor, ShortCursor, ShortDoubleCursor, ShortFloatCursor, ShortIntCursor, ShortLongCursor, ShortObjCursor<V>, ShortShortCursor

public interface Cursor

A mutable pointer to the element in an iteration. Cursor is a kind of hybrid between Java standard Iterator interface and System.Collections.IEnumerator interface from .NET framework.

Cursor interface design typically permits slightly faster implementation, than Iterator, so it is preferred in performance-critical code. On the other hand, isn't supported by Java's "for-each" syntax.

See the comparison of iteration ways in the library.

Cursors of updatable and immutable containers don't support remove() operation. More about mutability profiles.

See Also:
Java Iterator vs .NET IEnumerator – The Small Things Matter

Method Summary
 boolean moveNext()
          Moves the cursor forward to the next element (to the first element, if the cursor is in front of the first element).
 void remove()
          Removes the element to which the cursor currently points (optional operation).
 

Method Detail

moveNext

boolean moveNext()
Moves the cursor forward to the next element (to the first element, if the cursor is in front of the first element). Returns true if it exists, false otherwise. The cursor is located after the last element in the iteration and doesn't point to any element after the unsuccessful movement.

Returns:
true if the cursor has moved forward to the next element, false if the iteration has no more elements

remove

void remove()
Removes the element to which the cursor currently points (optional operation).

Throws IllegalStateException if the cursor isn't pointing to any element: if it is in front of the first element, after the last, or the current element has been already removed.

Throws:
UnsupportedOperationException - if the remove operation is not supported by this cursor
IllegalStateException - if this cursor is initially in front of the first element and moveNext() hasn't been called yet, or the previous call of moveNext returned false, or remove() has been already performed after the previous cursor movement