|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectstructure.AbstractIterator<ELTTYPE>
public abstract class AbstractIterator<ELTTYPE>
Abstract base class for portable iterator and enumeration implementation.
A general purpose iterator that implements both java.util.Iterator
and java.util.Enumeration. This class also implements the value()
method, providing multiple accesses, and the reset() method, which
allows the user to restart the traversal.
Typical usage:
Vector v = new Vector;
String s = "target";
...
Iterator t = v.iterator()();
// print members of vector that are greater than s
for (t.reset(); t.hasNext(); t.next())
{
if (s.compareTo(t.value()) < 0)
System.out.println(t.value());
}
Users of Java's Enumeration or Iterator
may treat the AbstractIterator as an Enumeration or
Iterator, respectively, without ill effect.
Appropriate care should be taken to make sure that the underlying data
structure is not modified while the traversal is active. Some
extensions of this class may choose to provide methods that modify
the structure --- the remove method of iterator
is one such possibility. Care should be taken to make sure that such
modifications are carefully synchronized, or limited to one active
traversal.
Iterator,
Enumeration| Constructor Summary | |
|---|---|
AbstractIterator()
Default constructor (for base class invocation). |
|
| Method Summary | |
|---|---|
abstract ELTTYPE |
get()
Returns the value currently being considered by the AbstractIterator. |
boolean |
hasMoreElements()
An Enumeration method that is equivalent to hasNext(). |
abstract boolean |
hasNext()
Returns true if the iterator has more elements to visit. |
abstract ELTTYPE |
next()
Moves, bumps, or "increments" the iterator along the traversal; returns the next value considered. |
ELTTYPE |
nextElement()
An Enumeration method that is equivalent to next(). |
void |
remove()
If implemented, removes the currently visited value from the structure. |
abstract void |
reset()
Reset iterator to the beginning of the structure. |
ELTTYPE |
value()
Deprecated. This method was deprecated in version 2 of the structure package. Use the get method. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public AbstractIterator()
| Method Detail |
|---|
public abstract void reset()
Iterator or
Enumeration implementation, but some traversals
may allow efficient multi-pass implementations with little
overhead. The user is encouraged to implement this method.
public abstract boolean hasNext()
hasMoreElements is an
Enumeration-required call to this method. The user
should override only this method.
hasNext in interface java.util.Iterator<ELTTYPE>hasMoreElements()public abstract ELTTYPE get()
Iterator nor
Enumeration. This method should be implemented,
however, to provide better support for for-loops.
public final ELTTYPE value()
Iterator nor
Enumeration. This method should be implemented,
however, to provide better support for for-loops.
public abstract ELTTYPE next()
value method.
This method is preferred over the nextElement method.
next in interface java.util.Iterator<ELTTYPE>hasMoreElements(),
value()public void remove()
remove should not be called unless it is overridden.
remove in interface java.util.Iterator<ELTTYPE>public final boolean hasMoreElements()
hasNext().
Extensions to this class should provide a hasNext
method.
hasMoreElements in interface java.util.Enumeration<ELTTYPE>public final ELTTYPE nextElement()
next().
Extensions to this class should provide a next method.
nextElement in interface java.util.Enumeration<ELTTYPE>
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||