/** * Gets an iterator that iterates through an array of {@link Iterator}s * one after another. * * @param <E> the element type * @param iterators the iterators to use, not null or empty or contain nulls * @return a combination iterator over the iterators * @throws NullPointerException if iterators array is null or contains a null */ public static <E> Iterator<E> chainedIterator(final Iterator<? extends E>... iterators) { return new IteratorChain<>(iterators); }
/** * Gets an iterator that iterates through a collections of {@link Iterator}s * one after another. * * @param <E> the element type * @param iterators the iterators to use, not null or empty or contain nulls * @return a combination iterator over the iterators * @throws NullPointerException if iterators collection is null or contains a null * @throws ClassCastException if the iterators collection contains the wrong object type */ public static <E> Iterator<E> chainedIterator(final Collection<Iterator<? extends E>> iterators) { return new IteratorChain<>(iterators); }
/** * Gets an iterator that iterates through two {@link Iterator}s * one after another. * * @param <E> the element type * @param iterator1 the first iterator to use, not null * @param iterator2 the second iterator to use, not null * @return a combination iterator over the iterators * @throws NullPointerException if either iterator is null */ public static <E> Iterator<E> chainedIterator(final Iterator<? extends E> iterator1, final Iterator<? extends E> iterator2) { // keep a version with two iterators to avoid the following warning in client code (Java 5 & 6) // "A generic array of E is created for a varargs parameter" return new IteratorChain<>(iterator1, iterator2); }
/** * Gets an iterator over all the sets in this composite. * <p> * This implementation uses an <code>IteratorChain</code>. * * @return an <code>IteratorChain</code> instance which supports * <code>remove()</code>. Iteration occurs over contained collections in * the order they were added, but this behavior should not be relied upon. * @see IteratorChain */ @Override public Iterator<E> iterator() { if (all.isEmpty()) { return EmptyIterator.<E>emptyIterator(); } final IteratorChain<E> chain = new IteratorChain<>(); for (final Set<E> item : all) { chain.addIterator(item.iterator()); } return chain; }
/** * Gets an iterator over all the collections in this composite. * <p> * This implementation uses an <code>IteratorChain</code>. * * @return an <code>IteratorChain</code> instance which supports * <code>remove()</code>. Iteration occurs over contained collections in * the order they were added, but this behavior should not be relied upon. * @see IteratorChain */ @Override public Iterator<E> iterator() { if (all.isEmpty()) { return EmptyIterator.<E>emptyIterator(); } final IteratorChain<E> chain = new IteratorChain<>(); for (final Collection<E> item : all) { chain.addIterator(item.iterator()); } return chain; }
@Override public Iterator<E> iterator() { return UnmodifiableIterator.decorate(new IteratorChain(Arrays.asList(used.iterator(),unused.iterator()))); }
/** * @inheritDoc */ public Enumeration getAttributeNames() { IteratorChain ic = new IteratorChain(m_attributes.keySet().iterator(),m_nonPortalSession.getAllAttributes().keySet().iterator()); return new IteratorEnumeration(ic); }
/** * @inheritDoc */ public Enumeration getAttributeNames() { Set<String> nonPortableAttributeNames = m_nonPortalSession.getAllAttributes().keySet(); IteratorChain ic = new IteratorChain(m_attributes.keySet().iterator(),nonPortableAttributeNames.iterator()); return new IteratorEnumeration(ic); }
@Override public Iterator<T> iterator() { IteratorChain<T> iterator = new IteratorChain<>(); for (IterableResult<T> result : this.results) { iterator.addIterator(result.iterator()); } return iterator; }
final Iterator<ByteBuffer> inxIter = new IteratorChain<ByteBuffer>(bbiterators);
IteratorChain chain = new IteratorChain(); if ( realChildren != null ) { chain.addIterator(realChildren);