public interface CharCursor extends Cursor
char
s.
Basic CharCursor
usage idiom is:
for (CharCursor cur = collection.cursor(); cur.moveNext();) {
// Work with cur.elem()
// Call cur.remove() to remove the current entry
}
CharCollection.cursor()
Modifier and Type | Method and Description |
---|---|
char |
elem()
Returns the element to which the cursor currently points.
|
void |
forEachForward(CharConsumer action)
Performs the given action for each element of the iteration after the cursor in forward
direction until all elements have been processed or the action throws an exception.
|
void forEachForward(@Nonnull CharConsumer action)
cur.forEachForward(action)
is exact equivalent of
while (cur.moveNext())
action.accept(cur.elem());
action
- the action to be performed for each elementchar elem()
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 removed
using Cursor.remove()
operation.
IllegalStateException
- if this cursor is initially in front of the first element
and Cursor.moveNext()
hasn't been called yet,
or the previous call of moveNext
returned false
,
or remove()
has been performed after the previous cursor movement