|
|||||||||
| Home >> All >> java >> [ util overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.util
Class Collections.SynchronizedListIterator

java.lang.Objectjava.util.Collections.SynchronizedIterator
java.util.Collections.SynchronizedListIterator
- All Implemented Interfaces:
- Iterator, ListIterator
- Enclosing class:
- Collections
- private static final class Collections.SynchronizedListIterator
- extends Collections.SynchronizedIterator
- implements ListIterator
- extends Collections.SynchronizedIterator
The implementation of SynchronizedList#listIterator(). This
iterator must "sync" on the same object as the list it iterates over.
| Field Summary | |
private ListIterator |
li
The wrapped iterator, stored both here and in the superclass to avoid excessive casting. |
(package private) java.lang.Object |
mutex
The object to synchronize on. |
| Constructor Summary | |
(package private) |
Collections.SynchronizedListIterator(java.lang.Object sync,
ListIterator li)
Only trusted code creates a wrapper, with the specified sync. |
| Method Summary | |
void |
add(java.lang.Object o)
Insert an element into the underlying list at the current position of the iterator (optional operation). |
boolean |
hasNext()
Returns true if objects can still be retrieved from the iterator
using next(). |
boolean |
hasPrevious()
Tests whether there are elements remaining in the underlying list in the reverse direction. |
java.lang.Object |
next()
Retrieves the next object in the underlying collection. |
int |
nextIndex()
Find the index of the element that would be returned by a call to next(). |
java.lang.Object |
previous()
Obtain the previous element from the underlying list. |
int |
previousIndex()
Find the index of the element that would be returned by a call to previous. |
void |
remove()
Removes the object that was last returned by next()
from the underlying collection. |
void |
set(java.lang.Object o)
Replace the element last returned by a call to next() or
previous() with a given object (optional operation). |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface java.util.ListIterator |
hasNext, next, remove |
| Field Detail |
li
private final ListIterator li
- The wrapped iterator, stored both here and in the superclass to
avoid excessive casting.
mutex
final java.lang.Object mutex
- The object to synchronize on. Package visible for use by subclass.
| Constructor Detail |
Collections.SynchronizedListIterator
Collections.SynchronizedListIterator(java.lang.Object sync, ListIterator li)
- Only trusted code creates a wrapper, with the specified sync.
| Method Detail |
add
public void add(java.lang.Object o)
- Insert an element into the underlying list at the current position of
the iterator (optional operation). The element is inserted in between
the element that would be returned by
previous()and the element that would be returned bynext(). After the insertion, a subsequent call to next is unaffected, but a call to previous returns the item that was added. The values returned by nextIndex() and previousIndex() are incremented. A lock is obtained on the mutex before the addition takes place.- Specified by:
addin interfaceListIterator
hasPrevious
public boolean hasPrevious()
- Tests whether there are elements remaining in the underlying list
in the reverse direction. In other words,
previous()will not fail with a NoSuchElementException. A lock is obtained on the mutex before the check takes place.- Specified by:
hasPreviousin interfaceListIterator
nextIndex
public int nextIndex()
- Find the index of the element that would be returned by a call to
next(). If hasNext() returnsfalse, this returns the list size. A lock is obtained on the mutex before the query takes place.- Specified by:
nextIndexin interfaceListIterator
previous
public java.lang.Object previous()
- Obtain the previous element from the underlying list. Repeated
calls to previous may be used to iterate backwards over the entire list,
or calls to next and previous may be used together to go forwards and
backwards. Alternating calls to next and previous will return the same
element. A lock is obtained on the mutex before the object is retrieved.
- Specified by:
previousin interfaceListIterator
previousIndex
public int previousIndex()
- Find the index of the element that would be returned by a call to
previous. If hasPrevious() returns
false, this returns -1. A lock is obtained on the mutex before the query takes place.- Specified by:
previousIndexin interfaceListIterator
set
public void set(java.lang.Object o)
- Replace the element last returned by a call to
next()orprevious()with a given object (optional operation). This method may only be called if neitheradd()norremove()have been called since the last call tonext()orprevious. A lock is obtained on the mutex before the list is modified.- Specified by:
setin interfaceListIterator
next
public java.lang.Object next()
- Retrieves the next object in the underlying collection.
A lock is obtained on the mutex before the collection is accessed.
hasNext
public boolean hasNext()
- Returns
trueif objects can still be retrieved from the iterator usingnext(). A lock is obtained on the mutex before the collection is accessed.
remove
public void remove()
- Removes the object that was last returned by
next()from the underlying collection. Only one call to this method is allowed per call to thenext()method, and it does not affect the value that will be returned bynext(). Thus, if element n was retrieved from the collection bynext(), it is this element that gets removed. Regardless of whether this takes place or not, element n+1 is still returned on the subsequentnext()call.
|
|||||||||
| Home >> All >> java >> [ util overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC