Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/changes/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<action type="fix" dev="ggregory" due-to="Naveed Khan, Gary Gregory">Fix TransformedMultiValuedMap.putAll(K, Iterable) NPE for null value transformer (#731).</action>
<action type="fix" dev="ggregory" due-to="Gary Gregory">Fix AbstractReferenceMap.ReferenceEntry.setValue(V) to throw NullPointerException on null input (contract).</action>
<action type="fix" dev="ggregory" due-to="Manfred Baedke, Gary Gregory" issue="COLLECTIONS-900">Preserve iteration state, subclass behavior, and later child additions when chaining IteratorChain instances. Reject detected cycles during traversal and removal (#730, #755).</action>
<action type="fix" issue="COLLECTIONS-722">Traverse nested iterator chains without recursion and reuse the active iterator path.</action>
<!-- ADD -->
<!-- UPDATE -->
<action type="update" dev="ggregory" due-to="Gary Gregory">Bump org.apache.commons:commons-parent from 104 to 107.</action>
Expand Down
11 changes: 2 additions & 9 deletions src/main/java/org/apache/commons/collections4/IteratorUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
import org.apache.commons.collections4.iterators.IteratorChain;
import org.apache.commons.collections4.iterators.IteratorEnumeration;
import org.apache.commons.collections4.iterators.IteratorIterable;
import org.apache.commons.collections4.iterators.LazyIteratorChain;
import org.apache.commons.collections4.iterators.ListIteratorWrapper;
import org.apache.commons.collections4.iterators.LoopingIterator;
import org.apache.commons.collections4.iterators.LoopingListIterator;
Expand Down Expand Up @@ -456,22 +455,16 @@ public static <E> Iterator<E> chainedIterator(final Iterator<? extends E> iterat

/**
* Gets an iterator that iterates through an {@link Iterator} of Iterators one after another.
* The returned iterator rejects a null source on first use.
*
* @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.
* @since 4.5.0-M3
*/
public static <E> Iterator<E> chainedIterator(final Iterator<? extends Iterator<? extends E>> iterators) {
return new LazyIteratorChain<E>() {

@Override
protected Iterator<? extends E> nextIterator(final int count) {
return iterators.hasNext() ? iterators.next() : null;
}
};
return IteratorChain.fromIterators(iterators);
}

/**
Expand Down
Loading
Loading