messif.utility
Class SortingIterator<T>

java.lang.Object
  extended by messif.utility.SortingIterator<T>
Type Parameters:
T - type of objects provided by the encapsulated collection of iterators
All Implemented Interfaces:
java.util.Iterator<T>

public class SortingIterator<T>
extends java.lang.Object
implements java.util.Iterator<T>

Iterator that retrieves the smallest object from a collection of iterators when its next method is called.


Field Summary
protected  java.util.Comparator<? super T> comparator
          The comparator used to sort the provided objects
 
Constructor Summary
SortingIterator(java.util.Collection<? extends java.util.Iterator<? extends T>> iterators, java.util.Comparator<? super T> comparator)
          Creates a new instance of SortingIterator.
 
Method Summary
 boolean hasNext()
           
 T next()
           
 void remove()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

comparator

protected final java.util.Comparator<? super T> comparator
The comparator used to sort the provided objects

Constructor Detail

SortingIterator

public SortingIterator(java.util.Collection<? extends java.util.Iterator<? extends T>> iterators,
                       java.util.Comparator<? super T> comparator)
Creates a new instance of SortingIterator.

Parameters:
iterators - the collection of iterators to get the objects from
comparator - the comparator used to sort the objects provided by iterators
Method Detail

hasNext

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

next

public T next()
Specified by:
next in interface java.util.Iterator<T>

remove

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