/** * Gets an iterator that iterates through a collections of {@link Iterator}s * one after another. * * @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 Iterator chainedIterator(Collection iterators) { return new IteratorChain(iterators); }
/** * Gets an iterator that iterates through an array of {@link Iterator}s * one after another. * * @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 Iterator chainedIterator(Iterator[] iterators) { return new IteratorChain(iterators); }
/** * Gets an iterator that iterates through two {@link Iterator}s * one after another. * * @param iterator1 the first iterators to use, not null * @param iterator2 the first iterators to use, not null * @return a combination iterator over the iterators * @throws NullPointerException if either iterator is null */ public static Iterator chainedIterator(Iterator iterator1, Iterator iterator2) { return new IteratorChain(iterator1, iterator2); }
/** * Gets an iterator that iterates through two {@link Iterator}s * one after another. * * @param iterator1 the first iterators to use, not null * @param iterator2 the first iterators to use, not null * @return a combination iterator over the iterators * @throws NullPointerException if either iterator is null */ public static Iterator chainedIterator(Iterator iterator1, Iterator iterator2) { return new IteratorChain(iterator1, iterator2); }
/** * Gets an iterator that iterates through an array of {@link Iterator}s * one after another. * * @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 Iterator chainedIterator(Iterator[] iterators) { return new IteratorChain(iterators); }
/** * Gets an iterator that iterates through a collections of {@link Iterator}s * one after another. * * @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 Iterator chainedIterator(Collection iterators) { return new IteratorChain(iterators); }
/** * 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 */ public Iterator iterator() { if (this.all.length == 0) { return EmptyIterator.INSTANCE; } IteratorChain chain = new IteratorChain(); for (int i = 0; i < this.all.length; ++i) { chain.addIterator(this.all[i].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 */ public Iterator iterator() { if (this.all.length == 0) { return EmptyIterator.INSTANCE; } IteratorChain chain = new IteratorChain(); for (int i = 0; i < this.all.length; ++i) { chain.addIterator(this.all[i].iterator()); } return chain; }
public Iterator iterator() { final IteratorChain chain = new IteratorChain(); for (Iterator it = keySet().iterator(); it.hasNext();) { chain.addIterator(new ValuesIterator(it.next())); } return chain; }
public Iterator makeEmptyIterator() { ArrayList list = new ArrayList(); return new IteratorChain(list.iterator()); }
public Iterator iterator() { final IteratorChain chain = new IteratorChain(); for (Iterator it = keySet().iterator(); it.hasNext();) { chain.addIterator(new ValuesIterator(it.next())); } return chain; }
public Iterator makeFullIterator() { IteratorChain chain = new IteratorChain(); chain.addIterator(list1.iterator()); chain.addIterator(list2.iterator()); chain.addIterator(list3.iterator()); return chain; }
public void testFirstIteratorIsEmptyBug() { List empty = new ArrayList(); List notEmpty = new ArrayList(); notEmpty.add("A"); notEmpty.add("B"); notEmpty.add("C"); IteratorChain chain = new IteratorChain(); chain.addIterator(empty.iterator()); chain.addIterator(notEmpty.iterator()); assertTrue("should have next",chain.hasNext()); assertEquals("A",chain.next()); assertTrue("should have next",chain.hasNext()); assertEquals("B",chain.next()); assertTrue("should have next",chain.hasNext()); assertEquals("C",chain.next()); assertTrue("should not have next",!chain.hasNext()); }
public void testEmptyChain() { IteratorChain chain = new IteratorChain(); assertEquals(false, chain.hasNext()); try { chain.next(); fail(); } catch (NoSuchElementException ex) {} try { chain.remove(); fail(); } catch (IllegalStateException ex) {} }
/** * Returns an iterator for the concatenation of all the given <code>iterators</code>. * * @param <T> * @param iterators * @return */ @SuppressWarnings("unchecked") public static <T> Iterator<T> iteratorChain(Iterator<? extends T>[] iterators) { return new IteratorChain(iterators); }
/** * Gets an iterator that iterates through a collections of {@link Iterator}s * one after another. * * @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 Iterator chainedIterator(Collection iterators) { return new IteratorChain(iterators); }
/** * Gets an iterator that iterates through two {@link Iterator}s * one after another. * * @param iterator1 the first iterators to use, not null * @param iterator2 the first iterators to use, not null * @return a combination iterator over the iterators * @throws NullPointerException if either iterator is null */ public static Iterator chainedIterator(Iterator iterator1, Iterator iterator2) { return new IteratorChain(iterator1, iterator2); }
public Iterator iterator() { IteratorChain chain = new IteratorChain(); if (_dirty != null && !_dirty.isEmpty()) chain.addIterator(_dirty.iterator()); if (_clean != null && !_clean.isEmpty()) chain.addIterator(_clean.iterator()); return chain; }
public Iterator iterator() { final IteratorChain chain = new IteratorChain(); for (Iterator it = keySet().iterator(); it.hasNext();) { chain.addIterator(new ValuesIterator(it.next())); } return chain; }
public Iterator iterator() { _iterated = true; IteratorChain chain = new IteratorChain(); chain.addIterator(new FilterIterator(itr(), this)); // note have to copy _ct.getAdded to prevent concurrent mod errors chain.addIterator(new ArrayList(_ct.getAdded()).iterator()); return new Itr(chain); }