Orbital library

orbital.util
Class QueuedSequenceIterator

java.lang.Object
  extended by orbital.util.QueuedSequenceIterator
All Implemented Interfaces:
java.io.Serializable, java.util.Iterator

public class QueuedSequenceIterator
extends java.lang.Object
implements java.util.Iterator, java.io.Serializable

A queued SequenceIterator represents the (mutable) logical concatenation of other iterators. It starts out with a list of iterators and reads from the first one until the end is reached, whereupon it reads from the second one, and so on, until the end is reached on the last of the contained iterators.

QueuedSequenceIterator is effectively a combination of SequenceIterator and QueuedIterator. It is introduced separately, since its construction is necessarily less performant than the unmodifiable version, SequenceIterator.

Author:
André Platzer
See Also:
SequenceIterator, QueuedIterator, Serialized Form
Invariants:
current ∈ iterators && (!hasNext() xor next() ∈ RES(current))

Constructor Summary
QueuedSequenceIterator(java.util.Iterator iterators)
          Create a new sequence iterator over an iterator of iterators.
QueuedSequenceIterator(java.util.Iterator[] iterators)
          Create a new sequence iterator over an array of iterators.
QueuedSequenceIterator(java.util.List iterators)
          Create a new sequence iterator over a list of iterators.
 
Method Summary
 void add(int index, java.lang.Object o)
          Insert an iterator at the specified position into this queued sequence iterator.
 boolean add(java.lang.Object o)
          Append an iterator to this queued sequence iterator.
 boolean hasNext()
           
 java.lang.Object next()
           
 void remove()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QueuedSequenceIterator

public QueuedSequenceIterator(java.util.Iterator iterators)
Create a new sequence iterator over an iterator of iterators.

Parameters:
iterators - is an iterator over iterators whose elements this SequenceIterator will provide, one after one.

QueuedSequenceIterator

public QueuedSequenceIterator(java.util.List iterators)
Create a new sequence iterator over a list of iterators.

Note that modifying iterators will result in a ConcurrentModificationException at runtime, as per general contract of list iterators.

Parameters:
iterators - is a list of iterators whose elements this SequenceIterator will provide, one after one.

QueuedSequenceIterator

public QueuedSequenceIterator(java.util.Iterator[] iterators)
Create a new sequence iterator over an array of iterators.

Parameters:
iterators - is an array of iterators whose elements this SequenceIterator will provide, one after one.
Method Detail

hasNext

public boolean hasNext()
Specified by:
hasNext in interface java.util.Iterator

next

public java.lang.Object next()
Specified by:
next in interface java.util.Iterator

remove

public void remove()
Specified by:
remove in interface java.util.Iterator

add

public boolean add(java.lang.Object o)
Append an iterator to this queued sequence iterator.


add

public void add(int index,
                java.lang.Object o)
Insert an iterator at the specified position into this queued sequence iterator.


Orbital library
1.3.0: 11 Apr 2009

Copyright © 1996-2009 André Platzer
All Rights Reserved.