/** * Constructs a new <code>CollatingIterator</code> that will use the * specified comparator to provide ordered iteration over the array of * iterators. * * @param comp the comparator to use to sort; must not be null, * unless you'll be invoking {@link #setComparator(Comparator)} later on. * @param iterators the array of iterators * @throws NullPointerException if iterators array is or contains null */ public CollatingIterator(final Comparator<? super E> comp, final Iterator<? extends E>[] iterators) { this(comp, iterators.length); for (final Iterator<? extends E> iterator : iterators) { addIterator(iterator); } }
/** * Constructs a new <code>CollatingIterator</code> that will use the * specified comparator to provide ordered iteration over the two given * iterators. * * @param comp the comparator to use to sort; must not be null, * unless you'll be invoking {@link #setComparator(Comparator)} later on. * @param a the first child ordered iterator * @param b the second child ordered iterator * @throws NullPointerException if either iterator is null */ public CollatingIterator(final Comparator<? super E> comp, final Iterator<? extends E> a, final Iterator<? extends E> b) { this(comp, 2); addIterator(a); addIterator(b); }
/** * Constructs a new <code>CollatingIterator</code> that will use the * specified comparator to provide ordered iteration over the collection of * iterators. * * @param comp the comparator to use to sort; must not be null, * unless you'll be invoking {@link #setComparator(Comparator)} later on. * @param iterators the collection of iterators * @throws NullPointerException if the iterators collection is or contains null * @throws ClassCastException if the iterators collection contains an * element that's not an {@link Iterator} */ public CollatingIterator(final Comparator<? super E> comp, final Collection<Iterator<? extends E>> iterators) { this(comp, iterators.size()); for (final Iterator<? extends E> iterator : iterators) { addIterator(iterator); } }