/** Creates a new document iterator that computes the OR of the given array of iterators. * @param documentIterator the iterators to be joined. * @throws IOException */ protected AbstractUnionDocumentIterator( final DocumentIterator... documentIterator ) throws IOException { super( documentIterator ); this.refArray = new int[ n ]; queue = new IntHeapSemiIndirectPriorityQueue( refArray ); intervalIterators = new Reference2ReferenceArrayMap<Index,IntervalIterator>( indices.size() ); currentIterators = new Reference2ReferenceArrayMap<Index,IntervalIterator>( indices.size() ); unmodifiableCurrentIterators = Reference2ReferenceMaps.unmodifiable( currentIterators ); // Only add to the queue nonempty iterators... for ( int i = 0; i < n; i++ ) if ( ( refArray[ i ] = documentIterator[ i ].nextDocument() ) != -1 ) queue.enqueue( i ); // If queue is empty, the process is over if ( queue.isEmpty() ) curr = END_OF_LIST; else { curr = refArray[ queue.first() ]; ahead = true; } front = new int[ queue.size() ]; }