T - public static interface C.List.Cursor<T>
A cursor points to an element of a List. It performs like ListIterator but differs in the following way:
| Modifier and Type | Method and Description |
|---|---|
C.List.Cursor<T> |
append(T t)
Add an element after the element this cursor points to.
|
C.List.Cursor<T> |
backward()
Move the cursor backward to make it point to the previous element to the current element
|
C.List.Cursor<T> |
drop()
Remove the current element this cursor points to.
|
C.List.Cursor<T> |
forward()
Move the cursor forward to make it point to the next element to the current element
|
T |
get()
Returns the element this cursor points to.
|
boolean |
hasNext()
Returns if the cursor can be moved forward to get the next element
|
boolean |
hasPrevious()
Returns if the cursor can be moved backward to get the previous element
|
int |
index()
Returns the index of the element to which the cursor pointed
|
boolean |
isDefined()
Returns true if the cursor is not obsolete and points to an element in the list
|
C.List.Cursor<T> |
parkLeft()
Park the cursor at the position before the first element.
|
C.List.Cursor<T> |
parkRight()
Park the cursor at the position after the last element
|
C.List.Cursor<T> |
prepend(T t)
Add an element in front of the element this cursor points to.
|
C.List.Cursor<T> |
set(T t)
Replace the element this cursor points to with the new element specified.
|
boolean isDefined()
Returns true if the cursor is not obsolete and points to an element in the list
int index()
Returns the index of the element to which the cursor pointed
boolean hasNext()
Returns if the cursor can be moved forward to get the next element
true if there are element after the cursor in the underline listboolean hasPrevious()
Returns if the cursor can be moved backward to get the previous element
true if there are element before the cursor in the underline listC.List.Cursor<T> forward() throws UnsupportedOperationException
Move the cursor forward to make it point to the next element to the current element
UnsupportedOperationException - if cannot move forward anymoreC.List.Cursor<T> backward() throws UnsupportedOperationException
Move the cursor backward to make it point to the previous element to the current element
UnsupportedOperationException - if cannot move backward anymoreC.List.Cursor<T> parkLeft()
Park the cursor at the position before the first element.
After calling this method, isDefined() shall return false
C.List.Cursor<T> parkRight()
Park the cursor at the position after the last element
After calling this method, isDefined() shall return false
T get() throws NoSuchElementException
Returns the element this cursor points to. If the cursor isn’t point to any element, calling to this method will trigger NoSuchElementException been thrown out. The only case the cursor doesn’t point to any element is when it is initialized in which case the cursor index is -1
NoSuchElementException - if the cursor isn’t point to any elementC.List.Cursor<T> set(T t) throws IndexOutOfBoundsException, NullPointerException
Replace the element this cursor points to with the new element specified.
t - the new element to be set to this cursorIndexOutOfBoundsException - if the cursor isn’t point to any elementNullPointerException - if when passing null value to this method and the underline list does not allow null valueC.List.Cursor<T> drop() throws NoSuchElementException, UnsupportedOperationException
Remove the current element this cursor points to. After the element is removed, the cursor points to the next element if there is next, or if there isn’t next element, the cursor points to the previous element, or if there is previous element neither, then the cursor points to -1 position and the current element is not defined
UnsupportedOperationException - if the operation is not supported by the underline container does not support removing elementsNoSuchElementException - if the cursor is parked either left or rightC.List.Cursor<T> prepend(T t) throws IndexOutOfBoundsException
Add an element in front of the element this cursor points to. After added, the cursor should still point to the current element
t - the element to be insertedIndexOutOfBoundsException - if the current element is undefinedC.List.Cursor<T> append(T t)
Add an element after the element this cursor points to. After added, the cursor should still point to the current element
t - the element to be addedCopyright © 2014–2019 OSGL (Open Source General Library). All rights reserved.