org.openstreetmap.osmosis.core.sort.common
Class MergingIterator<DataType>

java.lang.Object
  extended by org.openstreetmap.osmosis.core.sort.common.MergingIterator<DataType>
Type Parameters:
DataType - The object type to be sorted.
All Implemented Interfaces:
java.util.Iterator<DataType>, Releasable, ReleasableIterator<DataType>

public class MergingIterator<DataType>
extends java.lang.Object
implements ReleasableIterator<DataType>

This iterator examines a list of sorted input sources and merges them into a single sorted list.

Author:
Brett Henderson

Constructor Summary
MergingIterator(java.util.List<ReleasableIterator<DataType>> sources, java.util.Comparator<DataType> comparator)
          Creates a new instance.
 
Method Summary
 boolean hasNext()
          
 DataType next()
          
 void release()
          Performs resource cleanup tasks such as closing files, or database connections.
 void remove()
          Not supported.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MergingIterator

public MergingIterator(java.util.List<ReleasableIterator<DataType>> sources,
                       java.util.Comparator<DataType> comparator)
Creates a new instance.

Parameters:
sources - The list of data sources.
comparator - The comparator to be used for sorting.
Method Detail

hasNext

public boolean hasNext()

Specified by:
hasNext in interface java.util.Iterator<DataType>

next

public DataType next()

Specified by:
next in interface java.util.Iterator<DataType>

remove

public void remove()
Not supported. An UnsupportedOperationException is always thrown.

Specified by:
remove in interface java.util.Iterator<DataType>

release

public void release()
Performs resource cleanup tasks such as closing files, or database connections. This must be called after all processing is complete and may be called multiple times. Implementations must call release on any nested Releasable objects. It should be called within a finally block to ensure it is called in exception scenarios.

Specified by:
release in interface Releasable