Esempio n. 1
0
 public MergedIterator(final Iterator<T>[] iterators, final Comparator<T> comparator) {
   this(iterators.length, comparator);
   for (Iterator<T> iterator : iterators) {
     IteratorNode ctx = new IteratorNode(iterator);
     if (ctx.fetch()) _queue.add(ctx);
   }
 }
Esempio n. 2
0
 public MergedIterator(final List<Iterator<T>> iterators, final Comparator<T> comparator) {
   this(iterators.size(), comparator);
   for (Iterator<T> iterator : iterators) {
     IteratorNode ctx = new IteratorNode(iterator);
     if (ctx.fetch()) _queue.add(ctx);
   }
 }
Esempio n. 3
0
 @SuppressWarnings("unchecked")
 public T next() {
   IteratorNode ctx = (IteratorNode) _queue.top();
   T val = ctx._curVal;
   if (ctx.fetch()) {
     _queue.updateTop();
   } else {
     _queue.pop();
   }
   return val;
 }