Orbital library

orbital.util
Class QueuedIterator

java.lang.Object
  extended by orbital.util.DelegateCollection
      extended by orbital.util.DelegateList
          extended by orbital.util.QueuedIterator
All Implemented Interfaces:
java.io.Serializable, java.lang.Iterable, java.util.Collection, java.util.Iterator, java.util.List

public class QueuedIterator
extends DelegateList
implements java.util.Iterator, java.io.Serializable

QueuedIterator is an iterator that queues elements added to it and provides an iterator view to them.

Much like queues, elements added are returned in FIFO order.

The List implementation part of this class provides an interface to the internal data queue maintained. Objects will be returned (via iterator view) from the head of it, and therefore objects appended to it are returned in FIFO order.

Author:
André Platzer
See Also:
Serialized Form
Structure:
forwards List to super

Constructor Summary
QueuedIterator()
          Create a new non-synchronized queued iterator.
QueuedIterator(boolean synchronizedQueue)
          Create a new queued iterator.
 
Method Summary
 boolean addAll(java.util.Iterator i)
          Add all objects of an iterator to this queued iterator.
 boolean hasNext()
          Checks whether the queued iterator currently has a next element.
 java.lang.Object next()
          Returns the elements added to this queued iterator in FIFO order.
 void remove()
          Not supported.
 
Methods inherited from class orbital.util.DelegateList
add, addAll, get, indexOf, lastIndexOf, listIterator, listIterator, remove, set, setDelegatee, setDelegatee, subList
 
Methods inherited from class orbital.util.DelegateCollection
add, addAll, clear, contains, containsAll, equals, getDelegatee, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.List
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 

Constructor Detail

QueuedIterator

public QueuedIterator(boolean synchronizedQueue)
Create a new queued iterator.

Parameters:
synchronizedQueue - whether to use Collections.synchronizedList(java.util.List) on the buffering queue.

QueuedIterator

public QueuedIterator()
Create a new non-synchronized queued iterator.

Method Detail

hasNext

public boolean hasNext()
Checks whether the queued iterator currently has a next element.

Note: This state might change when someone added data.

Specified by:
hasNext in interface java.util.Iterator
See Also:
DelegateCollection.isEmpty()

next

public java.lang.Object next()
Returns the elements added to this queued iterator in FIFO order.

Specified by:
next in interface java.util.Iterator
Returns:
the first object added which has not yet been returned.

remove

public void remove()
Not supported.

Specified by:
remove in interface java.util.Iterator
Throws:
java.lang.UnsupportedOperationException - on every call.

addAll

public boolean addAll(java.util.Iterator i)
Add all objects of an iterator to this queued iterator.

See Also:
Functionals.foldRight(BinaryFunction, Object, Iterator)

Orbital library
1.3.0: 11 Apr 2009

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