public interface Cursor
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.
Modifier and Type | Method and Description |
---|---|
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).
|
boolean moveNext()
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.true
if the cursor has moved forward to the next element,
false
if the iteration has no more elementsvoid remove()
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.
UnsupportedOperationException
- if the remove
operation is not supported
by this cursorIllegalStateException
- 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