class MergeIterator implements MutableObjectIterator<E> {

	@Override
	public E next(E reuse) throws IOException {
		/* There are three ways to handle object reuse:
		 * 1) reuse and return the given object
		 * 2) ignore the given object and return a new object
		 * 3) exchange the given object for an existing object
		 *
		 * The first option is not available here as the return value has
		 * already been deserialized from the heap's top iterator. The second
		 * option avoids object reuse. The third option is implemented below
		 * by passing the given object to the heap's top iterator into which
		 * the next value will be deserialized.
		 */

		if (this.heap.size() > 0) {
			// get the smallest element
			final HeadStream<E> top = this.heap.peek();
			E result = top.getHead();

			// read an element
			if (!top.nextHead(reuse)) {
				this.heap.poll();
			} else {
				this.heap.adjustTop();
			}
			return result;
		}
		else {
			return null;
		}
	}

	public  MergeIterator(List<MutableObjectIterator<E>> iterators, TypeComparator<E> comparator);

}