java::util::Iterator Class Reference

Inheritance diagram for java::util::Iterator:

Inheritance graph
java::util::ListIteratorjava::lang::Interfacejava::lang::Object
[legend]
Collaboration diagram for java::util::Iterator:

Collaboration graph
java::lang::Interfacejava::lang::Object
[legend]

List of all members.


Detailed Description

An iterator over a collection.

Iterator takes the place of Enumeration in the Java collections framework. Iterators differ from enumerations in two ways:

Author:
Josh Bloch
Version:
1.16, 12/03/01
See also:
Collection

ListIterator

Since:
1.2

Public Member Functions

virtual jboolean hasNext ()=0
 Returns true if the iteration has more elements.
virtual ObjectRef next ()=0
 Returns the next element in the iteration.
virtual void remove ()=0
 Removes from the underlying collection the last element returned by the iterator (optional operation).

Static Public Member Functions

static Ref< IteratoremptyIterator ()
 The empty iterator (immutable).
static Ref< IteratorsingletonIterator (const ObjectRef &o)
 Returns an immutable iterator, only iterate the specified object.
static Ref< IteratorimmutableIterator (const Ref< Iterator > &i)
 Returns an unmodifiable view of the specified iterator.

Member Function Documentation

static Ref<Iterator> java::util::Iterator::emptyIterator (  )  [static]

The empty iterator (immutable).

static Ref<Iterator> java::util::Iterator::singletonIterator ( const ObjectRef o  )  [static]

Returns an immutable iterator, only iterate the specified object.

Parameters:
o the sole objecct to be iterated.
Returns:
an immutable iterator containing only the specified object.
Since:
1.3

static Ref<Iterator> java::util::Iterator::immutableIterator ( const Ref< Iterator > &  i  )  [static]

Returns an unmodifiable view of the specified iterator.

This method allows modules to provide users with "read-only" access to internal iterator. Query operations on the returned iterator "read through" to the specified iterator, and attempts to invoke the modify operation methods of the returned iterator will result in an UnsupportedOperationException.

Parameters:
i the iterator for which an unmodifiable view is to be returned.
Returns:
an unmodifiable iterator of the specified iterator.

virtual jboolean java::util::Iterator::hasNext (  )  [pure virtual]

Returns true if the iteration has more elements.

(In other words, returns true if next would return an element rather than throwing an exception.)

Returns:
true if the iterator has more elements.

virtual ObjectRef java::util::Iterator::next (  )  [pure virtual]

Returns the next element in the iteration.

Returns:
the next element in the iteration.
Exceptions:
NoSuchElementException iteration has no more elements.

virtual void java::util::Iterator::remove (  )  [pure virtual]

Removes from the underlying collection the last element returned by the iterator (optional operation).

This method can be called only once per call to next. The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method.

Exceptions:
UnsupportedOperationException if the remove operation is not supported by this Iterator.
IllegalStateException if the next method has not yet been called, or the remove method has already been called after the last call to the next method.


The documentation for this class was generated from the following file:
Generated on Fri May 16 11:56:48 2008 for CrossPlatformJavaLikeC++API by  doxygen 1.5.3