E - the class of the elements to iterate over.public static final class CollectionsExt.NonModifyingCyclicIterator<E> extends Object implements CyclicIterator<E>
CollectionsExt.ImmutableCyclicList.| Modifier and Type | Field and Description |
|---|---|
private CyclicIterator<E> |
wrapped |
| Constructor and Description |
|---|
NonModifyingCyclicIterator(CyclicIterator<E> wrapped) |
| 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. |
int |
hashCode() |
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
CyclicIterator.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.
|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitforEachRemainingprivate final CyclicIterator<E> wrapped
NonModifyingCyclicIterator(CyclicIterator<E> wrapped)
public int getFirstIndex()
CyclicIteratorgetFirstIndex in interface CyclicIterator<E>CyclicList.cyclicIterator(int)public int getIndex()
CyclicIteratorgetIndex in interface CyclicIterator<E>public CyclicList<E> getCyclicList()
CyclicIteratorcyclicList.cyclicIterator(int).getCyclicList() ==
cyclicList again.getCyclicList in interface CyclicIterator<E>null.CyclicList.cyclicIterator(int)public boolean hasNext()
CyclicIteratortrue if the iteration has more elements.
(In other words, returns true
if next would return an element
rather than throwing an exception.)public E next()
CyclicIteratorprevious to go back and forth.
(Note that alternating calls to next
and previous
will return the same element repeatedly.)public boolean hasPrev()
CyclicIteratortrue 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.)hasPrev in interface CyclicIterator<E>true if the list iterator has more elements
when traversing the list in the reverse direction.public E previous()
CyclicIteratornext to go back and forth.
(Note that alternating calls
to next and previous
will return the same element repeatedly.)previous in interface CyclicIterator<E>public int getNextIndexOf(E obj)
CyclicIteratornext
which equals the given one, if possible;
otherwise returns -1.getNextIndexOf in interface CyclicIterator<E>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.
public void setIndex(int index)
CyclicIteratorCyclicIterator.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.setIndex in interface CyclicIterator<E>index - an arbitrary int value,
which may also be negative.public void add(E obj)
CyclicIteratornext, 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.)
add in interface CyclicIterator<E>obj - the element to be inserted.CyclicIterator.addAll(java.util.List<? extends E>)public void addAll(List<? extends E> list)
CyclicIteratornext, 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).
addAll in interface CyclicIterator<E>list - the list to be inserted.CyclicIterator.add(E)public void set(E obj)
CyclicIteratornext 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.set in interface CyclicIterator<E>obj - the element with which to replace the last element
returned by next or previous.public void remove()
CyclicIteratorCyclicList
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.public void refresh()
CyclicIteratorCyclicIterator.next().
On the other hand, CyclicIterator.previous() throws an exception.refresh in interface CyclicIterator<E>public boolean retEquals(CyclicIterator<?> other)
retEquals in interface CyclicIterator<E>public boolean equals(Object other)
CyclicIteratorfalse if other is not an instance of
CyclicIterator.
The implementation of this interface should not play a role.equals in interface CyclicIterator<E>equals in class Objectother - another Object.false if other is not an instance of
CyclicIterator.
The implementation of this interface should not play a role.public double dist(CyclicIterator<E> other)
dist in interface CyclicIterator<E>Copyright © 2012–2018 Simuline Organization (l2r). All rights reserved.