java.util

Interface Iterator<E>

Known Subinterfaces:
EventIterator, EventListenerIterator, HibernateIterator, ListIterator<E>, MapIterator, NodeIterator, NodeTypeIterator, OrderedIterator, OrderedMapIterator, PropertyIterator, RangeIterator, ResettableIterator, ResettableListIterator, RowIterator, VersionIterator, XMLEventReader
Known Implementing Classes:
AbstractDualBidiMap.BidiMapIterator, AbstractDualBidiMap.EntrySetIterator, AbstractDualBidiMap.KeySetIterator, AbstractDualBidiMap.ValuesIterator, AbstractHashedMap.EntrySetIterator, AbstractHashedMap.HashIterator, AbstractHashedMap.HashMapIterator, AbstractHashedMap.KeySetIterator, AbstractHashedMap.ValuesIterator, AbstractIteratorDecorator, AbstractLinkedList.LinkedListIterator, AbstractLinkedList.LinkedSubListIterator, AbstractLinkedMap.EntrySetIterator, AbstractLinkedMap.KeySetIterator, AbstractLinkedMap.LinkIterator, AbstractLinkedMap.LinkMapIterator, AbstractLinkedMap.ValuesIterator, AbstractListIteratorDecorator, AbstractMapIteratorDecorator, AbstractOrderedMapIteratorDecorator, AncestorContext, AppendIteratorFilter, ArrayIterator, ArrayIterator, ArrayListIterator, ASTIterator, ASTParentsFirstIterator, AttributeContext, BeanContextSupport.BCSIterator, ByteIteratorIterator, ByteListIteratorListIterator, CharArraySet.CharArraySetIterator, CharIteratorIterator, CharListIteratorListIterator, ChildContext, CollatingIterator, ConfigurationKey.KeyIterator, Counter, CursorableLinkedList.Cursor, CursorableLinkedList.Cursor, CursorableLinkedList.SubCursor, CursorableLinkedList.Cursor, DataMapping.EmptyIt, DefaultConfigurationKey.KeyIterator, DescendantContext, DirDocMaker.Iterator, DoubleIteratorIterator, DoubleListIteratorListIterator, DualTreeBidiMap.BidiOrderedMapIterator, EmptyIterator, EmptyIterator, EmptyListIterator, EmptyMapIterator, EmptyOrderedIterator, EmptyOrderedMapIterator, EntrySetMapIterator, EnumerationIterator, EnumerationIterator, EvalContext, EventReaderDelegate, Expression.PointerIterator, Expression.ValueIterator, FilterIterator, FilterListIterator, FloatIteratorIterator, FloatListIteratorListIterator, HitIterator, InitialContext, IntIteratorIterator, IntListIteratorListIterator, IteratorChain, IteratorFilterSupport.EnumerationIterator, IteratorGenerator, IteratorImpl, JoinedIterator, LazyIterator, LineIterator, ListIteratorWrapper, LongIteratorIterator, LongListIteratorListIterator, LoopingIterator, LoopingListIterator, LRUMemoryCache.IteratorWrapper, MemberMapping.SingleIt, MergeIteratorFilter, NamespaceContext, NodeSetContext, ObjectArrayIterator, ObjectArrayListIterator, ObjectGraphIterator, ParentContext, PrecedingOrFollowingContext, PredicateContext, PredicatedList.PredicatedListIterator, ProxyIterator, ProxyListIterator, ResultSetIterator, ResultSetIterator, ReverseListIterator, RootContext, Scanner, SelfContext, ShortIteratorIterator, ShortListIteratorListIterator, SingletonIterator, SingletonIterator, SingletonListIterator, SortIteratorFilter, StrTokenizer, SubsetIteratorFilter, TransformedList.TransformedListIterator, TransformIterator, UnionContext, UniqueFilterIterator, UnmodifiableIterator, UnmodifiableListIterator, UnmodifiableMapIterator, UnmodifiableOrderedMapIterator, ValueRecordsAggregate.MyIterator, WebTable.WebTableRowIterator

public interface Iterator<E>

An iterator over a collection. Iterator takes the place of Enumeration in the Java collections framework. Iterators differ from enumerations in two ways:

This interface is a member of the ../../../guide/collections/index.html"> Java Collections Framework.

Since:
1.2
See Also:
Collection, ListIterator, Enumeration

Method Summary

boolean
hasNext()
Returns true if the iteration has more elements.
E
next()
Returns the next element in the iteration.
void
remove()
Removes from the underlying collection the last element returned by the iterator (optional operation).

Method Details

hasNext

public boolean hasNext()
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.
Usages and Demos :

View More Examples of hasNext()
   1: 
   2: import java.util.Iterator;
   3: import java.util.NoSuchElementException;
   4:         ...
   5: public class DelegateFeatureIterator implements FeatureIterator {
   6:     Iterator delegate;
   7:     private FeatureCollection collection;
   8:         ...
   9:     public DelegateFeatureIterator( FeatureCollection collection, Iterator iterator ){
  10:         delegate = iterator;
  11:         ...
  12:     public boolean hasNext() {
  13:         return delegate != null && delegate.hasNext();

View Full Code Here
   1: import java.util.Collection;
   2: import java.util.Iterator;
   3: 
   4:         ...
   5: 
   6:     private Iterator _iter;
   7:     
   8:         ...
   9:     public MemResourceIterator(Collection resources) {
  10:         _iter = resources.iterator();
  11:     }
  12:         ...
  13:     public boolean hasNext() {
  14:         return _iter != null && _iter.hasNext();

View Full Code Here
   1: 
   2: import java.util.Iterator;
   3: import java.util.Map;
   4:         ...
   5: 
   6:     private void assertNextEquals(Object expected, Iterator iterator) {
   7:         ...
   8:         assertTrue("Expected to pull of another item from iterator : " + expected, iterator.hasNext());
   9:         assertEquals(expected, iterator.next());
  10:         ...
  11:     private void assertNextEntryEquals(Object expectedKey, Object expectedValue, Iterator iterator) {
  12:         assertTrue("Expected to pull of another item from iterator : " + expectedKey + "=" + expectedValue, iterator.hasNext());

View Full Code Here
   1: 
   2: import java.util.Iterator;
   3: 
   4:         ...
   5: 
   6:     private void assertNextEquals(Object expected, Iterator iterator) {
   7:         ...
   8:         assertTrue("Expected to pull of another item from iterator : " + expected, iterator.hasNext());
   9:         assertEquals(expected, iterator.next());
  10:         ...
  11:     private void assertNoMore(Iterator iterator) {
  12:         assertFalse("Should be no more items in iterator", iterator.hasNext());

View Full Code Here
   1: 
   2: import java.util.Iterator;
   3: import java.util.Map;
   4:         ...
   5:         int totalFeatures = targetFC.size();
   6:         for (Iterator i = targetFC.iterator();
   7:         ...
   8:             i.hasNext() && !monitor.isCancelRequested();
   9:             ) {

View Full Code Here

next

public E next()
Returns the next element in the iteration. Calling this method repeatedly until the hasNext() method returns false will return each element in the underlying collection exactly once.
Returns:
the next element in the iteration.
Throws:
NoSuchElementException - iteration has no more elements.
Usages and Demos :

View More Examples of next()
   1:             try {
   2:                 java.util.Iterator i = builder.getNodes(query).iterator();
   3:         ...
   4:                 return i.hasNext() ? ((MMObjectNode) i.next()) : null;
   5:             } catch (Exception e) {
   6:                 return null;
   7:             }

View Full Code Here
   1: import java.util.ArrayList;
   2: import java.util.Iterator;
   3: import java.util.List;
   4:         ...
   5:         
   6:         Iterator openedRangeIterator = openedRanges.iterator();
   7:         LongRange openedRange = openedRangeIterator.hasNext() ?
   8:         ...
   9:                 (LongRange) openedRangeIterator.next() : null;
  10:         
  11:         ...
  12:                     openedRange = openedRangeIterator.hasNext() ?
  13:                         (LongRange) openedRangeIterator.next() : null;

View Full Code Here
   1: import java.util.ArrayList;
   2: import java.util.Iterator;
   3: import java.util.List;
   4:         ...
   5:         
   6:         Iterator openedRangeIterator = openedRanges.iterator();
   7:         DoubleRange openedRange = openedRangeIterator.hasNext() ?
   8:         ...
   9:                 (DoubleRange) openedRangeIterator.next() : null;
  10:         
  11:         ...
  12:                     openedRange = openedRangeIterator.hasNext() ?
  13:                         (DoubleRange) openedRangeIterator.next() : null;

View Full Code Here
   1:     if (map == null) return null;
   2:     Iterator it = map.values().iterator();
   3:         ...
   4:     return it.hasNext() ? (Label) it.next() : null;
   5:   }
   6:         ...
   7: 
   8:     Iterator iterator = this.labels.values().iterator();
   9:     while (iterator.hasNext()) {
  10:         ...
  11:       Map map = (Map) iterator.next();

View Full Code Here
   1:    private final LinkedList pdvs = new LinkedList();
   2:    private final Iterator it;
   3:    private PDVImpl curPDV = null;
   4:         ...
   5:       }
   6:       this.it = pdvs.iterator();
   7:    }
   8:         ...
   9:       }
  10:       return it.hasNext() ? (PDV)it.next() : null;
  11:    }
  12:         ...
  13:       sb.append("P-DATA-TF[pdulen=").append(pdulen).append("]");
  14:       Iterator it = pdvs.iterator();

View Full Code Here

remove

public void remove()
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.
Throws:
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.
Usages and Demos :

View More Examples of remove()
   1: import java.util.Iterator;
   2: 
   3:         ...
   4: public class IteratorDelegator implements Iterator {
   5:         ...
   6:     public Iterator i;
   7:     
   8:         ...
   9:     public void remove() {
  10:         i.remove();

View Full Code Here
   1: 
   2: import java.util.Iterator;
   3:         ...
   4: public class TypedIterator implements Iterator
   5: {
   6:         ...
   7:     public Class type;
   8:     public Iterator imp;
   9:     public TypedIterator(Class type,Iterator imp)
  10:         ...
  11:     {
  12:         imp.remove();

View Full Code Here
   1: 
   2: import java.util.Iterator;
   3: 
   4:         ...
   5: public abstract class AbstractAdapterIterator implements Iterator {
   6: 
   7:         ...
   8:     protected Iterator iter;
   9:     
  10:         ...
  11:     public void remove() {
  12:         iter.remove();

View Full Code Here
   1: 
   2: public class IteratorAdapter implements Iterator {
   3:         ...
   4:     Iterator iterator;
   5:     AbstractAdapter adapter;
   6:         ...
   7:     public void remove() {
   8:     iterator.remove();
   9:     }

View Full Code Here
   1: 
   2:         Iterator numbers = list.iterator();
   3:         while(numbers.hasNext()){
   4:         ...
   5:             if(num.intValue() < 0){
   6:                 numbers.remove();
   7:             }
   8:         ...
   9: 
  10:         numbers = list.iterator();
  11:         while(numbers.hasNext()){

View Full Code Here