E - the class of the elements to iterate over.public interface CyclicIterator<E> extends Iterator<E>
CyclicList.
CyclicIterator corresponds with CyclicLists
as Iterators or ListIterators do
with Lists.CyclicList,
ListIterator| Modifier and Type | Method and Description |
|---|---|
void |
add(E obj)
Inserts the specified element into the underlying cyclic list
(optional operation).
|
void |
addAll(List<? extends E> list)
Inserts the specified list into the underlying cyclic list
(optional operation).
|
double |
dist(CyclicIterator<E> other) |
boolean |
equals(Object other)
Returns
false if other is not an instance of
CyclicIterator. |
CyclicList<E> |
getCyclicList()
Returns the cyclic list to which this iterator points.
|
int |
getFirstIndex()
Returns the cursor of this iterator
immediately after it has been created
(if not modified since then which is currently not possible.).
|
int |
getIndex()
Returns the current cursor of this iterator.
|
int |
getNextIndexOf(E obj)
Returns the (non-negative) index
of the next object returned by
next
which equals the given one, if possible;
otherwise returns -1. |
boolean |
hasNext()
Returns
true if the iteration has more elements. |
boolean |
hasPrev()
Returns
true if this iterator has more elements when
traversing the cyclic list in the reverse direction. |
E |
next()
Returns the next element in the interation.
|
E |
previous()
Returns the previous element in the cyclic list.
|
void |
refresh()
Reinitialize this iterator without changing the cursor
but such that all elements of the corresponding cyclic list
may be accessed successively through
next(). |
void |
remove()
Removes from the underlying
CyclicList
the last element returned by next or previous
(optional operation). |
boolean |
retEquals(CyclicIterator<?> other) |
void |
set(E obj)
Replaces the last element
returned by
next or previous
with the specified element (optional operation). |
void |
setIndex(int index)
Sets the given index as cursor of this iterator.
|
forEachRemainingint getFirstIndex()
CyclicList.cyclicIterator(int)int getIndex()
CyclicList<E> getCyclicList()
cyclicList.cyclicIterator(int).getCyclicList() ==
cyclicList again.null.CyclicList.cyclicIterator(int)boolean hasNext()
true if the iteration has more elements.
(In other words, returns true
if next would return an element
rather than throwing an exception.)E next()
previous to go back and forth.
(Note that alternating calls to next
and previous
will return the same element repeatedly.)next in interface Iterator<E>NoSuchElementException - iteration has no more elements.boolean hasPrev()
true if this iterator has more elements when
traversing the cyclic list in the reverse direction.
(In other words, returns true
if previous would return an element
rather than throwing an exception.)true if the list iterator has more elements
when traversing the list in the reverse direction.E previous()
next to go back and forth.
(Note that alternating calls
to next and previous
will return the same element repeatedly.)NoSuchElementException - if the iteration has no previous element.int getNextIndexOf(E obj)
next
which equals the given one, if possible;
otherwise returns -1.obj - an object.ind in {0,...,this.list.size()-1}
satisfying obj.equals(this.list.get(ind))
if possible;
-1 if there is no such index.
void setIndex(int index)
getCyclicList() is not empty.
Then it.setIndex(index); return it.getIndex();
returns index again
up to it.getCyclicList().size().
For it.getCyclicList().isEmpty(),
this method does not modify this iterator.index - an arbitrary int value,
which may also be negative.void add(E obj)
next, if any,
and after the next element
that would be returned by previous, if any.
(If the cyclic list is empty,
the new element becomes the sole element on the cyclic list.)
The new element is inserted before the implicit cursor:
a subsequent call to next would be unaffected,
and a subsequent call to previous
would return the new element.
(This call increases by one the value that would be returned by a call
to nextIndex or previousIndex.)
obj - the element to be inserted.UnsupportedOperationException - if the add method is not supported by this iterator.ClassCastException - if the class of the specified element
prevents it from being added to the underlying cyclic list.IllegalArgumentException - if some aspect of this element
prevents it from being added to the underlying cyclic list.addAll(java.util.List<? extends E>)void addAll(List<? extends E> list)
next, if any,
and after the next element
that would be returned by previous, if any.
(If the cyclic list is empty,
the new cyclic list comprises the given list.)
The given list is inserted before the implicit cursor:
a subsequent call to next would be unaffected,
and a subsequent call to previous
would return the given list in reversed order.
(This call increases by list.size()
the value that would be returned by a call
to nextIndex or previousIndex.)
If list.size() contains a single element e,
addAll(list) is equivalent with add(e).
list - the list to be inserted.UnsupportedOperationException - if the add method is not supported by this iterator.ClassCastException - if the class of the an element in the specified list
prevents it from being added to the underlying list.IllegalArgumentException - if some aspect of the an element in the specified list
prevents it from being added to the underlying list.add(E)void set(E obj)
next or previous
with the specified element (optional operation).
This call can be made only
if neither ListIterator.remove nor add
have been called after the last call to
next or previous.obj - the element with which to replace the last element
returned by next or previous.UnsupportedOperationException - if the set operation
is not supported by this iterator.ClassCastException - if the class of the specified element
prevents it from being added to this cyclic list.IllegalArgumentException - if some aspect of the specified element
prevents it from being added to this list.IllegalStateException - if neither next nor previous
have been called,
or remove or add have been called
after the last call to next or previous.void remove()
CyclicList
the last element returned by next or previous
(optional operation).
This method can be called only once
per call to next or previous.
It can be made only if add has not been called after
the last call to next or previous.remove in interface Iterator<E>UnsupportedOperationException - if the remove operation
is not supported by this CyclicIterator.IllegalStateException - if neither next nor previous
have been called,
or remove or add have been called
after the last call to next or previous.void refresh()
next().
On the other hand, previous() throws an exception.boolean retEquals(CyclicIterator<?> other)
boolean equals(Object other)
false if other is not an instance of
CyclicIterator.
The implementation of this interface should not play a role.double dist(CyclicIterator<E> other)
Copyright © 2012–2018 Simuline Organization (l2r). All rights reserved.