// Path: src/main/java/ch/picard/ppimapbuilder/util/iterators/IteratorChain.java
// public class IteratorChain<E> implements Iterator<E> {
// 
// 	/**
// 	 * The chain of iterators
// 	 */
// 	private final Queue<Iterator<? extends E>> iteratorChain = new LinkedList<Iterator<? extends E>>();
// 
// 	/**
// 	 * The current iterator
// 	 */
// 	private Iterator<? extends E> currentIterator = null;
// 
// 	/**
// 	 * Construct an IteratorChain with no Iterators.
// 	 * <p/>
// 	 * You will normally use {@link #addIterator(Iterator)} to add some
// 	 * iterators after using this constructor.
// 	 */
// 	public IteratorChain() {
// 		super();
// 	}
// 
// 	/**
// 	 * Add an Iterator to the end of the chain
// 	 *
// 	 * @param iterator Iterator to add
// 	 * @throws IllegalStateException if I've already started iterating
// 	 * @throws NullPointerException  if the iterator is null
// 	 */
// 	public void addIterator(final Iterator<? extends E> iterator) {
// 		iteratorChain.add(iterator);
// 	}
// 
// 	/**
// 	 * Returns the remaining number of Iterators in the current IteratorChain.
// 	 *
// 	 * @return Iterator count
// 	 */
// 	public int size() {
// 		return iteratorChain.size();
// 	}
// 
// 	/**
// 	 * Updates the current iterator field to ensure that the current Iterator is
// 	 * not exhausted
// 	 */
// 	protected void updateCurrentIterator() {
// 		if (currentIterator == null) {
// 			if (iteratorChain.isEmpty()) {
// 				currentIterator = new EmptyIterator<E>();
// 			} else {
// 				currentIterator = iteratorChain.remove();
// 			}
// 			// set last used iterator here, in case the user calls remove
// 			// before calling hasNext() or next() (although they shouldn't)
// 		}
// 
// 		while (currentIterator.hasNext() == false && !iteratorChain.isEmpty()) {
// 			currentIterator = iteratorChain.remove();
// 		}
// 	}
// 
// 	/**
// 	 * Return true if any Iterator in the IteratorChain has a remaining element.
// 	 *
// 	 * @return true if elements remain
// 	 */
// 	public boolean hasNext() {
// 		updateCurrentIterator();
// 		return currentIterator.hasNext();
// 	}
// 
// 	/**
// 	 * Returns the next Object of the current Iterator
// 	 *
// 	 * @return Object from the current Iterator
// 	 * @throws java.util.NoSuchElementException if all the Iterators are
// 	 *                                          exhausted
// 	 */
// 	public E next() {
// 		updateCurrentIterator();
// 		return currentIterator.next();
// 	}
// 
// 	@Override
// 	public void remove() {}
// 
// }


import ch.picard.ppimapbuilder.util.iterators.IteratorChain;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
package ch.picard.ppimapbuilder.util.concurrent;



/**
 * an Iterator producing a "stream" of object from a list of concurrent iterator requests
 * @param <T>
 */
public class ConcurrentFetcherIterator<T> implements Iterator<T> {

	private boolean canceled = false;
// Path: src/main/java/ch/picard/ppimapbuilder/util/iterators/IteratorChain.java
// public class IteratorChain<E> implements Iterator<E> {
// 
// 	/**
// 	 * The chain of iterators
// 	 */
// 	private final Queue<Iterator<? extends E>> iteratorChain = new LinkedList<Iterator<? extends E>>();
// 
// 	/**
// 	 * The current iterator
// 	 */
// 	private Iterator<? extends E> currentIterator = null;
// 
// 	/**
// 	 * Construct an IteratorChain with no Iterators.
// 	 * <p/>
// 	 * You will normally use {@link #addIterator(Iterator)} to add some
// 	 * iterators after using this constructor.
// 	 */
// 	public IteratorChain() {
// 		super();
// 	}
// 
// 	/**
// 	 * Add an Iterator to the end of the chain
// 	 *
// 	 * @param iterator Iterator to add
// 	 * @throws IllegalStateException if I've already started iterating
// 	 * @throws NullPointerException  if the iterator is null
// 	 */
// 	public void addIterator(final Iterator<? extends E> iterator) {
// 		iteratorChain.add(iterator);
// 	}
// 
// 	/**
// 	 * Returns the remaining number of Iterators in the current IteratorChain.
// 	 *
// 	 * @return Iterator count
// 	 */
// 	public int size() {
// 		return iteratorChain.size();
// 	}
// 
// 	/**
// 	 * Updates the current iterator field to ensure that the current Iterator is
// 	 * not exhausted
// 	 */
// 	protected void updateCurrentIterator() {
// 		if (currentIterator == null) {
// 			if (iteratorChain.isEmpty()) {
// 				currentIterator = new EmptyIterator<E>();
// 			} else {
// 				currentIterator = iteratorChain.remove();
// 			}
// 			// set last used iterator here, in case the user calls remove
// 			// before calling hasNext() or next() (although they shouldn't)
// 		}
// 
// 		while (currentIterator.hasNext() == false && !iteratorChain.isEmpty()) {
// 			currentIterator = iteratorChain.remove();
// 		}
// 	}
// 
// 	/**
// 	 * Return true if any Iterator in the IteratorChain has a remaining element.
// 	 *
// 	 * @return true if elements remain
// 	 */
// 	public boolean hasNext() {
// 		updateCurrentIterator();
// 		return currentIterator.hasNext();
// 	}
// 
// 	/**
// 	 * Returns the next Object of the current Iterator
// 	 *
// 	 * @return Object from the current Iterator
// 	 * @throws java.util.NoSuchElementException if all the Iterators are
// 	 *                                          exhausted
// 	 */
// 	public E next() {
// 		updateCurrentIterator();
// 		return currentIterator.next();
// 	}
// 
// 	@Override
// 	public void remove() {}
// 
// }


// Path: src/main/java/ch/picard/ppimapbuilder/util/concurrent/ConcurrentFetcherIterator.java
import ch.picard.ppimapbuilder.util.iterators.IteratorChain;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;

package ch.picard.ppimapbuilder.util.concurrent;



/**
 * an Iterator producing a "stream" of object from a list of concurrent iterator requests
 * @param <T>
 */
public class ConcurrentFetcherIterator<T> implements Iterator<T> {

	private boolean canceled = false;
	private final IteratorChain<T> innerIterator;