- Close HTML tags
- Whitespace before tags
- Remove dead inline comments
This commit is contained in:
Gary Gregory 2024-10-19 09:14:36 -04:00
parent b3d29d56d8
commit 5f23d725ee
21 changed files with 91 additions and 5 deletions

View File

@ -28,9 +28,11 @@ import org.apache.commons.collections4.ResettableIterator;
* that you have an object array, the * that you have an object array, the
* {@link org.apache.commons.collections4.iterators.ObjectArrayIterator ObjectArrayIterator} * {@link org.apache.commons.collections4.iterators.ObjectArrayIterator ObjectArrayIterator}
* class is a better choice, as it will perform better. * class is a better choice, as it will perform better.
* </p>
* <p> * <p>
* The iterator implements a {@link #reset} method, allowing the reset of * The iterator implements a {@link #reset} method, allowing the reset of
* the iterator back to the start if required. * the iterator back to the start if required.
* </p>
* *
* @param <E> the type of elements returned by this iterator. * @param <E> the type of elements returned by this iterator.
* @since 1.0 * @since 1.0
@ -114,7 +116,6 @@ public class ArrayIterator<E> implements ResettableIterator<E> {
} }
} }
// Properties
/** /**
* Gets the array that this iterator is iterating over. * Gets the array that this iterator is iterating over.
* *
@ -144,7 +145,6 @@ public class ArrayIterator<E> implements ResettableIterator<E> {
return startIndex; return startIndex;
} }
// Iterator interface
/** /**
* Returns true if there are more elements to return from the array. * Returns true if there are more elements to return from the array.
* *

View File

@ -27,10 +27,11 @@ import org.apache.commons.collections4.ResettableListIterator;
* The array can be either an array of object or of primitives. If you know * The array can be either an array of object or of primitives. If you know
* that you have an object array, the {@link ObjectArrayListIterator} * that you have an object array, the {@link ObjectArrayListIterator}
* class is a better choice, as it will perform better. * class is a better choice, as it will perform better.
* * </p>
* <p> * <p>
* This iterator does not support {@link #add(Object)} or {@link #remove()}, as the array * This iterator does not support {@link #add(Object)} or {@link #remove()}, as the array
* cannot be changed in size. The {@link #set(Object)} method is supported however. * cannot be changed in size. The {@link #set(Object)} method is supported however.
* </p>
* *
* @param <E> the type of elements returned by this iterator. * @param <E> the type of elements returned by this iterator.
* @see org.apache.commons.collections4.iterators.ArrayIterator * @see org.apache.commons.collections4.iterators.ArrayIterator
@ -105,7 +106,6 @@ public class ArrayListIterator<E> extends ArrayIterator<E>
throw new UnsupportedOperationException("add() method is not supported"); throw new UnsupportedOperationException("add() method is not supported");
} }
// ListIterator interface
/** /**
* Returns true if there are previous elements to return from the array. * Returns true if there are previous elements to return from the array.
* *
@ -182,6 +182,7 @@ public class ArrayListIterator<E> extends ArrayIterator<E>
* <p> * <p>
* This method sets the element that was returned by the last call * This method sets the element that was returned by the last call
* to {@link #next()} of {@link #previous()}. * to {@link #next()} of {@link #previous()}.
* </p>
* <p> * <p>
* <b>Note:</b> {@link java.util.ListIterator} implementations that support * <b>Note:</b> {@link java.util.ListIterator} implementations that support
* {@code add()} and {@code remove()} only allow {@code set()} to be called * {@code add()} and {@code remove()} only allow {@code set()} to be called
@ -189,6 +190,7 @@ public class ArrayListIterator<E> extends ArrayIterator<E>
* Javadoc for more details). Since this implementation does * Javadoc for more details). Since this implementation does
* not support {@code add()} or {@code remove()}, {@code set()} may be * not support {@code add()} or {@code remove()}, {@code set()} may be
* called as often as desired. * called as often as desired.
* </p>
* *
* @param o the element to set * @param o the element to set
* @throws IllegalStateException if {@link #next()} or {@link #previous()} has not been called * @throws IllegalStateException if {@link #next()} or {@link #previous()} has not been called

View File

@ -27,10 +27,12 @@ import java.util.Objects;
* The {@code offset} corresponds to the position of the first element to * The {@code offset} corresponds to the position of the first element to
* be returned from the decorated iterator, and {@code max} is the maximum * be returned from the decorated iterator, and {@code max} is the maximum
* number of elements to be returned at most. * number of elements to be returned at most.
* </p>
* <p> * <p>
* In case an offset parameter other than 0 is provided, the decorated * In case an offset parameter other than 0 is provided, the decorated
* iterator is immediately advanced to this position, skipping all elements * iterator is immediately advanced to this position, skipping all elements
* before that position. * before that position.
* </p>
* *
* @param <E> the type of elements returned by this iterator. * @param <E> the type of elements returned by this iterator.
* @since 4.1 * @since 4.1
@ -55,6 +57,7 @@ public class BoundedIterator<E> implements Iterator<E> {
* <p> * <p>
* The iterator is immediately advanced until it reaches the position at {@code offset}, * The iterator is immediately advanced until it reaches the position at {@code offset},
* incurring O(n) time. * incurring O(n) time.
* </p>
* *
* @param iterator the iterator to be decorated * @param iterator the iterator to be decorated
* @param offset the index of the first element of the decorated iterator to return * @param offset the index of the first element of the decorated iterator to return
@ -123,6 +126,7 @@ public class BoundedIterator<E> implements Iterator<E> {
* to this position upon creation. A call to {@link #remove()} will still result in an * to this position upon creation. A call to {@link #remove()} will still result in an
* {@link IllegalStateException} if no explicit call to {@link #next()} has been made prior * {@link IllegalStateException} if no explicit call to {@link #next()} has been made prior
* to calling {@link #remove()}. * to calling {@link #remove()}.
* </p>
*/ */
@Override @Override
public void remove() { public void remove() {

View File

@ -34,6 +34,7 @@ import org.apache.commons.collections4.list.UnmodifiableList;
* Given two ordered {@link Iterator} instances {@code A} and * Given two ordered {@link Iterator} instances {@code A} and
* {@code B}, the {@link #next} method on this iterator will return the * {@code B}, the {@link #next} method on this iterator will return the
* lesser of {@code A.next()} and {@code B.next()}. * lesser of {@code A.next()} and {@code B.next()}.
* </p>
* *
* @param <E> the type of elements returned by this iterator. * @param <E> the type of elements returned by this iterator.
* @since 2.1 * @since 2.1

View File

@ -26,6 +26,7 @@ import org.apache.commons.collections4.ResettableIterator;
* This class provides an implementation of an empty iterator. * This class provides an implementation of an empty iterator.
* This class provides for binary compatibility between Commons Collections * This class provides for binary compatibility between Commons Collections
* 2.1.1 and 3.1 due to issues with {@code IteratorUtils}. * 2.1.1 and 3.1 due to issues with {@code IteratorUtils}.
* </p>
* *
* @param <E> the type of elements returned by this iterator. * @param <E> the type of elements returned by this iterator.
* @since 2.1.1 and 3.1 * @since 2.1.1 and 3.1
@ -34,6 +35,7 @@ public class EmptyIterator<E> extends AbstractEmptyIterator<E> {
/** /**
* Singleton instance of the iterator. * Singleton instance of the iterator.
*
* @since 3.1 * @since 3.1
*/ */
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
@ -41,6 +43,7 @@ public class EmptyIterator<E> extends AbstractEmptyIterator<E> {
/** /**
* Singleton instance of the iterator. * Singleton instance of the iterator.
*
* @since 2.1.1 and 3.1 * @since 2.1.1 and 3.1
*/ */
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
@ -48,6 +51,7 @@ public class EmptyIterator<E> extends AbstractEmptyIterator<E> {
/** /**
* Gets a typed empty iterator instance. * Gets a typed empty iterator instance.
*
* @param <E> the element type * @param <E> the element type
* @return Iterator&lt;E&gt; * @return Iterator&lt;E&gt;
*/ */
@ -57,6 +61,7 @@ public class EmptyIterator<E> extends AbstractEmptyIterator<E> {
/** /**
* Gets a typed resettable empty iterator instance. * Gets a typed resettable empty iterator instance.
*
* @param <E> the element type * @param <E> the element type
* @return ResettableIterator&lt;E&gt; * @return ResettableIterator&lt;E&gt;
*/ */

View File

@ -26,6 +26,7 @@ import org.apache.commons.collections4.ResettableListIterator;
* This class provides an implementation of an empty list iterator. This class * This class provides an implementation of an empty list iterator. This class
* provides for binary compatibility between Commons Collections 2.1.1 and 3.1 * provides for binary compatibility between Commons Collections 2.1.1 and 3.1
* due to issues with {@code IteratorUtils}. * due to issues with {@code IteratorUtils}.
* </p>
* *
* @param <E> the type of elements returned by this iterator. * @param <E> the type of elements returned by this iterator.
* @since 2.1.1 and 3.1 * @since 2.1.1 and 3.1
@ -34,6 +35,7 @@ public class EmptyListIterator<E> extends AbstractEmptyIterator<E> implements Re
/** /**
* Singleton instance of the iterator. * Singleton instance of the iterator.
*
* @since 3.1 * @since 3.1
*/ */
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
@ -41,6 +43,7 @@ public class EmptyListIterator<E> extends AbstractEmptyIterator<E> implements Re
/** /**
* Singleton instance of the iterator. * Singleton instance of the iterator.
*
* @since 2.1.1 and 3.1 * @since 2.1.1 and 3.1
*/ */
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
@ -48,6 +51,7 @@ public class EmptyListIterator<E> extends AbstractEmptyIterator<E> implements Re
/** /**
* Gets a typed instance of the iterator. * Gets a typed instance of the iterator.
*
* @param <E> the element type * @param <E> the element type
* @return {@link ListIterator}&lt;E&gt; * @return {@link ListIterator}&lt;E&gt;
*/ */
@ -57,6 +61,7 @@ public class EmptyListIterator<E> extends AbstractEmptyIterator<E> implements Re
/** /**
* Gets a typed instance of the iterator. * Gets a typed instance of the iterator.
*
* @param <E> the element type * @param <E> the element type
* @return {@link ResettableListIterator}&lt;E&gt; * @return {@link ResettableListIterator}&lt;E&gt;
*/ */

View File

@ -26,6 +26,7 @@ import org.apache.commons.collections4.Predicate;
* <p> * <p>
* This iterator decorates the underlying iterator, only allowing through * This iterator decorates the underlying iterator, only allowing through
* those elements that match the specified {@link Predicate Predicate}. * those elements that match the specified {@link Predicate Predicate}.
* </p>
* *
* @param <E> the type of elements returned by this iterator. * @param <E> the type of elements returned by this iterator.
* @since 1.0 * @since 1.0

View File

@ -26,6 +26,7 @@ import org.apache.commons.collections4.Predicate;
* <p> * <p>
* This iterator decorates the underlying iterator, only allowing through * This iterator decorates the underlying iterator, only allowing through
* those elements that match the specified {@link Predicate Predicate}. * those elements that match the specified {@link Predicate Predicate}.
* </p>
* *
* @param <E> the type of elements returned by this iterator. * @param <E> the type of elements returned by this iterator.
* @since 2.0 * @since 2.0

View File

@ -29,22 +29,27 @@ import java.util.Queue;
* method from the Iterator interface is called, the IteratorChain will delegate * method from the Iterator interface is called, the IteratorChain will delegate
* to a single underlying Iterator. The IteratorChain will invoke the Iterators * to a single underlying Iterator. The IteratorChain will invoke the Iterators
* in sequence until all Iterators are exhausted. * in sequence until all Iterators are exhausted.
* </p>
* <p> * <p>
* Under many circumstances, linking Iterators together in this manner is more * Under many circumstances, linking Iterators together in this manner is more
* efficient (and convenient) than reading out the contents of each Iterator * efficient (and convenient) than reading out the contents of each Iterator
* into a List and creating a new Iterator. * into a List and creating a new Iterator.
* </p>
* <p> * <p>
* Calling a method that adds new Iterator <i>after a method in the Iterator * Calling a method that adds new Iterator <i>after a method in the Iterator
* interface has been called</i> will result in an UnsupportedOperationException. * interface has been called</i> will result in an UnsupportedOperationException.
* </p>
* <p> * <p>
* NOTE: As from version 3.0, the IteratorChain may contain no iterators. In * NOTE: As from version 3.0, the IteratorChain may contain no iterators. In
* this case the class will function as an empty iterator. * this case the class will function as an empty iterator.
* </p>
* <p> * <p>
* NOTE: As from version 4.0, the IteratorChain stores the iterators in a queue * NOTE: As from version 4.0, the IteratorChain stores the iterators in a queue
* and removes any reference to them as soon as they are not used anymore. Thus, * and removes any reference to them as soon as they are not used anymore. Thus,
* the methods {@code setIterator(Iterator)} and {@code getIterators()} have been * the methods {@code setIterator(Iterator)} and {@code getIterators()} have been
* removed and {@link #size()} will return the number of remaining iterators in * removed and {@link #size()} will return the number of remaining iterators in
* the queue. * the queue.
* </p>
* *
* @param <E> the type of elements in this iterator. * @param <E> the type of elements in this iterator.
* @since 2.1 * @since 2.1
@ -74,6 +79,7 @@ public class IteratorChain<E> implements Iterator<E> {
* <p> * <p>
* You will normally use {@link #addIterator(Iterator)} to add some * You will normally use {@link #addIterator(Iterator)} to add some
* iterators after using this constructor. * iterators after using this constructor.
* </p>
*/ */
public IteratorChain() { public IteratorChain() {
} }
@ -84,6 +90,7 @@ public class IteratorChain<E> implements Iterator<E> {
* <p> * <p>
* This method takes a collection of iterators. The newly constructed * This method takes a collection of iterators. The newly constructed
* iterator will iterate through each one of the input iterators in turn. * iterator will iterate through each one of the input iterators in turn.
* </p>
* *
* @param iteratorChain the collection of iterators, not null * @param iteratorChain the collection of iterators, not null
* @throws NullPointerException if iterators collection is or contains null * @throws NullPointerException if iterators collection is or contains null
@ -102,9 +109,11 @@ public class IteratorChain<E> implements Iterator<E> {
* This method takes one iterator. The newly constructed iterator will * This method takes one iterator. The newly constructed iterator will
* iterate through that iterator. Thus calling this constructor on its own * iterate through that iterator. Thus calling this constructor on its own
* will have no effect other than decorating the input iterator. * will have no effect other than decorating the input iterator.
* </p>
* <p> * <p>
* You will normally use {@link #addIterator(Iterator)} to add some more * You will normally use {@link #addIterator(Iterator)} to add some more
* iterators after using this constructor. * iterators after using this constructor.
* </p>
* *
* @param iterator the first child iterator in the IteratorChain, not null * @param iterator the first child iterator in the IteratorChain, not null
* @throws NullPointerException if the iterator is null * @throws NullPointerException if the iterator is null
@ -118,6 +127,7 @@ public class IteratorChain<E> implements Iterator<E> {
* <p> * <p>
* This method takes an array of iterators. The newly constructed iterator * This method takes an array of iterators. The newly constructed iterator
* will iterate through each one of the input iterators in turn. * will iterate through each one of the input iterators in turn.
* </p>
* *
* @param iteratorChain the array of iterators, not null * @param iteratorChain the array of iterators, not null
* @throws NullPointerException if iterators array is or contains null * @throws NullPointerException if iterators array is or contains null
@ -133,6 +143,7 @@ public class IteratorChain<E> implements Iterator<E> {
* <p> * <p>
* This method takes two iterators. The newly constructed iterator will * This method takes two iterators. The newly constructed iterator will
* iterate through each one of the input iterators in turn. * iterate through each one of the input iterators in turn.
* </p>
* *
* @param first the first child iterator in the IteratorChain, not null * @param first the first child iterator in the IteratorChain, not null
* @param second the second child iterator in the IteratorChain, not null * @param second the second child iterator in the IteratorChain, not null

View File

@ -25,9 +25,11 @@ import java.util.Iterator;
* method from the Iterator interface is called, the LazyIteratorChain will delegate * method from the Iterator interface is called, the LazyIteratorChain will delegate
* to a single underlying Iterator. The LazyIteratorChain will invoke the Iterators * to a single underlying Iterator. The LazyIteratorChain will invoke the Iterators
* in sequence until all Iterators are exhausted. * in sequence until all Iterators are exhausted.
* </p>
* <p> * <p>
* The Iterators are provided by {@link #nextIterator(int)} which has to be overridden by * The Iterators are provided by {@link #nextIterator(int)} which has to be overridden by
* subclasses and allows to lazily create the Iterators as they are accessed: * subclasses and allows to lazily create the Iterators as they are accessed:
* </p>
* <pre> * <pre>
* return new LazyIteratorChain&lt;String&gt;() { * return new LazyIteratorChain&lt;String&gt;() {
* protected Iterator&lt;String&gt; nextIterator(int count) { * protected Iterator&lt;String&gt; nextIterator(int count) {
@ -39,9 +41,11 @@ import java.util.Iterator;
* Once the inner Iterator's {@link Iterator#hasNext()} method returns false, * Once the inner Iterator's {@link Iterator#hasNext()} method returns false,
* {@link #nextIterator(int)} will be called to obtain another iterator, and so on * {@link #nextIterator(int)} will be called to obtain another iterator, and so on
* until {@link #nextIterator(int)} returns null, indicating that the chain is exhausted. * until {@link #nextIterator(int)} returns null, indicating that the chain is exhausted.
* </p>
* <p> * <p>
* NOTE: The LazyIteratorChain may contain no iterators. In this case the class will * NOTE: The LazyIteratorChain may contain no iterators. In this case the class will
* function as an empty iterator. * function as an empty iterator.
* </p>
* *
* @param <E> the type of elements in this iterator. * @param <E> the type of elements in this iterator.
* @since 4.0 * @since 4.0
@ -94,6 +98,7 @@ public abstract class LazyIteratorChain<E> implements Iterator<E> {
* Gets the next iterator after the previous one has been exhausted. * Gets the next iterator after the previous one has been exhausted.
* <p> * <p>
* This method <b>MUST</b> return null when there are no more iterators. * This method <b>MUST</b> return null when there are no more iterators.
* </p>
* *
* @param count the number of time this method has been called (starts with 1) * @param count the number of time this method has been called (starts with 1)
* @return the next iterator, or null if there are no more. * @return the next iterator, or null if there are no more.
@ -106,6 +111,7 @@ public abstract class LazyIteratorChain<E> implements Iterator<E> {
* As with next() and hasNext(), this method calls remove() on the underlying Iterator. * As with next() and hasNext(), this method calls remove() on the underlying Iterator.
* Therefore, this method may throw an UnsupportedOperationException if the underlying * Therefore, this method may throw an UnsupportedOperationException if the underlying
* Iterator does not support this method. * Iterator does not support this method.
* </p>
* *
* @throws UnsupportedOperationException if the remove operator is not * @throws UnsupportedOperationException if the remove operator is not
* supported by the underlying Iterator * supported by the underlying Iterator

View File

@ -38,10 +38,13 @@ import org.apache.commons.collections4.ResettableListIterator;
* This class allows a regular {@code Iterator} to behave as a * This class allows a regular {@code Iterator} to behave as a
* {@code ListIterator}. It achieves this by building a list internally * {@code ListIterator}. It achieves this by building a list internally
* of as the underlying iterator is traversed. * of as the underlying iterator is traversed.
* </p>
* <p> * <p>
* The optional operations of {@code ListIterator} are not supported for plain {@code Iterator}s. * The optional operations of {@code ListIterator} are not supported for plain {@code Iterator}s.
* </p>
* <p> * <p>
* This class implements ResettableListIterator from Commons Collections 3.2. * This class implements ResettableListIterator from Commons Collections 3.2.
* </p>
* *
* @param <E> the type of elements in this iterator. * @param <E> the type of elements in this iterator.
* @since 2.1 * @since 2.1

View File

@ -29,9 +29,11 @@ import org.apache.commons.collections4.ResettableIterator;
* The iterator will loop continuously around the provided elements, unless * The iterator will loop continuously around the provided elements, unless
* there are no elements in the collection to begin with, or all the elements * there are no elements in the collection to begin with, or all the elements
* have been {@link #remove removed}. * have been {@link #remove removed}.
* </p>
* <p> * <p>
* Concurrent modifications are not directly supported, and for most collection * Concurrent modifications are not directly supported, and for most collection
* implementations will throw a ConcurrentModificationException. * implementations will throw a ConcurrentModificationException.
* </p>
* *
* @param <E> the type of elements returned by this iterator. * @param <E> the type of elements returned by this iterator.
* @since 3.0 * @since 3.0
@ -48,6 +50,7 @@ public class LoopingIterator<E> implements ResettableIterator<E> {
* <p> * <p>
* There is no way to reset an Iterator instance without recreating it from * There is no way to reset an Iterator instance without recreating it from
* the original source, so the Collection must be passed in. * the original source, so the Collection must be passed in.
* </p>
* *
* @param collection the collection to wrap * @param collection the collection to wrap
* @throws NullPointerException if the collection is null * @throws NullPointerException if the collection is null
@ -62,6 +65,7 @@ public class LoopingIterator<E> implements ResettableIterator<E> {
* <p> * <p>
* Returns false only if the collection originally had zero elements, or * Returns false only if the collection originally had zero elements, or
* all the elements have been {@link #remove removed}. * all the elements have been {@link #remove removed}.
* </p>
* *
* @return {@code true} if there are more elements * @return {@code true} if there are more elements
*/ */
@ -74,6 +78,7 @@ public class LoopingIterator<E> implements ResettableIterator<E> {
* Returns the next object in the collection. * Returns the next object in the collection.
* <p> * <p>
* If at the end of the collection, return the first element. * If at the end of the collection, return the first element.
* </p>
* *
* @return the next object * @return the next object
* @throws NoSuchElementException if there are no elements * @throws NoSuchElementException if there are no elements
@ -96,11 +101,13 @@ public class LoopingIterator<E> implements ResettableIterator<E> {
* This feature is only supported if the underlying collection's * This feature is only supported if the underlying collection's
* {@link Collection#iterator()} method returns an implementation * {@link Collection#iterator()} method returns an implementation
* that supports it. * that supports it.
* </p>
* <p> * <p>
* This method can only be called after at least one {@link #next} method call. * This method can only be called after at least one {@link #next} method call.
* After a removal, the remove method may not be called again until another * After a removal, the remove method may not be called again until another
* next has been performed. If the {@link #reset} is called, then remove may * next has been performed. If the {@link #reset} is called, then remove may
* not be called until {@link #next} is called again. * not be called until {@link #next} is called again.
* </p>
*/ */
@Override @Override
public void remove() { public void remove() {

View File

@ -30,10 +30,12 @@ import org.apache.commons.collections4.ResettableListIterator;
* The iterator will loop continuously around the provided list, * The iterator will loop continuously around the provided list,
* unless there are no elements in the collection to begin with, or * unless there are no elements in the collection to begin with, or
* all of the elements have been {@link #remove removed}. * all of the elements have been {@link #remove removed}.
* </p>
* <p> * <p>
* Concurrent modifications are not directly supported, and for most * Concurrent modifications are not directly supported, and for most
* collection implementations will throw a * collection implementations will throw a
* ConcurrentModificationException. * ConcurrentModificationException.
* </p>
* *
* @param <E> the type of elements returned by this iterator. * @param <E> the type of elements returned by this iterator.
* @since 3.2 * @since 3.2
@ -51,6 +53,7 @@ public class LoopingListIterator<E> implements ResettableListIterator<E> {
* There is no way to reset a ListIterator instance without * There is no way to reset a ListIterator instance without
* recreating it from the original source, so the List must be * recreating it from the original source, so the List must be
* passed in and a reference to it held. * passed in and a reference to it held.
* </p>
* *
* @param list the list to wrap * @param list the list to wrap
* @throws NullPointerException if the list is null * @throws NullPointerException if the list is null
@ -66,10 +69,12 @@ public class LoopingListIterator<E> implements ResettableListIterator<E> {
* The element is inserted before the next element that would be * The element is inserted before the next element that would be
* returned by {@link #next}, if any, and after the next element * returned by {@link #next}, if any, and after the next element
* that would be returned by {@link #previous}, if any. * that would be returned by {@link #previous}, if any.
* </p>
* <p> * <p>
* This feature is only supported if the underlying list's * This feature is only supported if the underlying list's
* {@link List#listIterator} method returns an implementation * {@link List#listIterator} method returns an implementation
* that supports it. * that supports it.
* </p>
* *
* @param obj the element to insert * @param obj the element to insert
* @throws UnsupportedOperationException if the add method is not * @throws UnsupportedOperationException if the add method is not
@ -85,6 +90,7 @@ public class LoopingListIterator<E> implements ResettableListIterator<E> {
* <p> * <p>
* Returns false only if the list originally had zero elements, or * Returns false only if the list originally had zero elements, or
* all elements have been {@link #remove removed}. * all elements have been {@link #remove removed}.
* </p>
* *
* @return {@code true} if there are more elements * @return {@code true} if there are more elements
*/ */
@ -98,6 +104,7 @@ public class LoopingListIterator<E> implements ResettableListIterator<E> {
* <p> * <p>
* Returns false only if the list originally had zero elements, or * Returns false only if the list originally had zero elements, or
* all elements have been {@link #remove removed}. * all elements have been {@link #remove removed}.
* </p>
* *
* @return {@code true} if there are more elements * @return {@code true} if there are more elements
*/ */
@ -114,6 +121,7 @@ public class LoopingListIterator<E> implements ResettableListIterator<E> {
* Returns the next object in the list. * Returns the next object in the list.
* <p> * <p>
* If at the end of the list, returns the first element. * If at the end of the list, returns the first element.
* </p>
* *
* @return the object after the last element returned * @return the object after the last element returned
* @throws NoSuchElementException if there are no elements in the list * @throws NoSuchElementException if there are no elements in the list
@ -137,6 +145,7 @@ public class LoopingListIterator<E> implements ResettableListIterator<E> {
* As would be expected, if the iterator is at the physical end of * As would be expected, if the iterator is at the physical end of
* the underlying list, 0 is returned, signifying the beginning of * the underlying list, 0 is returned, signifying the beginning of
* the list. * the list.
* </p>
* *
* @return the index of the element that would be returned if next() were called * @return the index of the element that would be returned if next() were called
* @throws NoSuchElementException if there are no elements in the list * @throws NoSuchElementException if there are no elements in the list
@ -158,6 +167,7 @@ public class LoopingListIterator<E> implements ResettableListIterator<E> {
* <p> * <p>
* If at the beginning of the list, return the last element. Note * If at the beginning of the list, return the last element. Note
* that in this case, traversal to find that element takes linear time. * that in this case, traversal to find that element takes linear time.
* </p>
* *
* @return the object before the last element returned * @return the object before the last element returned
* @throws NoSuchElementException if there are no elements in the list * @throws NoSuchElementException if there are no elements in the list
@ -186,6 +196,7 @@ public class LoopingListIterator<E> implements ResettableListIterator<E> {
* As would be expected, if at the iterator is at the physical * As would be expected, if at the iterator is at the physical
* beginning of the underlying list, the list's size minus one is * beginning of the underlying list, the list's size minus one is
* returned, signifying the end of the list. * returned, signifying the end of the list.
* </p>
* *
* @return the index of the element that would be returned if previous() were called * @return the index of the element that would be returned if previous() were called
* @throws NoSuchElementException if there are no elements in the list * @throws NoSuchElementException if there are no elements in the list
@ -208,6 +219,7 @@ public class LoopingListIterator<E> implements ResettableListIterator<E> {
* This feature is only supported if the underlying list's * This feature is only supported if the underlying list's
* {@link List#iterator()} method returns an implementation * {@link List#iterator()} method returns an implementation
* that supports it. * that supports it.
* </p>
* <p> * <p>
* This method can only be called after at least one {@link #next} * This method can only be called after at least one {@link #next}
* or {@link #previous} method call. After a removal, the remove * or {@link #previous} method call. After a removal, the remove
@ -215,6 +227,7 @@ public class LoopingListIterator<E> implements ResettableListIterator<E> {
* {@link #previous} has been performed. If the {@link #reset} is * {@link #previous} has been performed. If the {@link #reset} is
* called, then remove may not be called until {@link #next} or * called, then remove may not be called until {@link #next} or
* {@link #previous} is called again. * {@link #previous} is called again.
* </p>
* *
* @throws UnsupportedOperationException if the remove method is * @throws UnsupportedOperationException if the remove method is
* not supported by the iterator implementation of the underlying * not supported by the iterator implementation of the underlying
@ -240,6 +253,7 @@ public class LoopingListIterator<E> implements ResettableListIterator<E> {
* This feature is only supported if the underlying list's * This feature is only supported if the underlying list's
* {@link List#listIterator} method returns an implementation * {@link List#listIterator} method returns an implementation
* that supports it. * that supports it.
* </p>
* *
* @param obj the element with which to replace the last element returned * @param obj the element with which to replace the last element returned
* @throws UnsupportedOperationException if the set method is not * @throws UnsupportedOperationException if the set method is not

View File

@ -28,6 +28,7 @@ import org.w3c.dom.NodeList;
* <p> * <p>
* This iterator does not support {@link #remove()} as a {@link NodeList} does not support * This iterator does not support {@link #remove()} as a {@link NodeList} does not support
* removal of items. * removal of items.
* </p>
* *
* @since 4.0 * @since 4.0
* @see NodeList * @see NodeList

View File

@ -25,9 +25,11 @@ import org.apache.commons.collections4.ResettableIterator;
* <p> * <p>
* This iterator does not support {@link #remove}, as the object array cannot be * This iterator does not support {@link #remove}, as the object array cannot be
* structurally modified. * structurally modified.
* </p>
* <p> * <p>
* The iterator implements a {@link #reset} method, allowing the reset of the iterator * The iterator implements a {@link #reset} method, allowing the reset of the iterator
* back to the start if required. * back to the start if required.
* </p>
* *
* @param <E> the type of elements returned by this iterator. * @param <E> the type of elements returned by this iterator.
* @since 3.0 * @since 3.0

View File

@ -25,9 +25,11 @@ import org.apache.commons.collections4.ResettableListIterator;
* <p> * <p>
* This iterator does not support {@link #add} or {@link #remove}, as the object array * This iterator does not support {@link #add} or {@link #remove}, as the object array
* cannot be structurally modified. The {@link #set} method is supported however. * cannot be structurally modified. The {@link #set} method is supported however.
* </p>
* <p> * <p>
* The iterator implements a {@link #reset} method, allowing the reset of the iterator * The iterator implements a {@link #reset} method, allowing the reset of the iterator
* back to the start if required. * back to the start if required.
* </p>
* *
* @param <E> the type of elements returned by this iterator. * @param <E> the type of elements returned by this iterator.
* @see org.apache.commons.collections4.iterators.ObjectArrayIterator * @see org.apache.commons.collections4.iterators.ObjectArrayIterator
@ -172,13 +174,15 @@ public class ObjectArrayListIterator<E> extends ObjectArrayIterator<E>
* <p> * <p>
* This method sets the element that was returned by the last call * This method sets the element that was returned by the last call
* to {@link #next()} of {@link #previous()}. * to {@link #next()} of {@link #previous()}.
* * </p>
* <p>
* <b>Note:</b> {@link java.util.ListIterator} implementations that support {@code add()} * <b>Note:</b> {@link java.util.ListIterator} implementations that support {@code add()}
* and {@code remove()} only allow {@code set()} to be called once per call * and {@code remove()} only allow {@code set()} to be called once per call
* to {@code next()} or {@code previous} (see the {@link java.util.ListIterator} * to {@code next()} or {@code previous} (see the {@link java.util.ListIterator}
* Javadoc for more details). Since this implementation does not support * Javadoc for more details). Since this implementation does not support
* {@code add()} or {@code remove()}, {@code set()} may be * {@code add()} or {@code remove()}, {@code set()} may be
* called as often as desired. * called as often as desired.
* </p>
* *
* @param obj the object to set into the array * @param obj the object to set into the array
* @throws IllegalStateException if next() has not yet been called. * @throws IllegalStateException if next() has not yet been called.

View File

@ -30,8 +30,10 @@ import org.apache.commons.collections4.Transformer;
* The iteration starts from a single root object. * The iteration starts from a single root object.
* It uses a {@code Transformer} to extract the iterators and elements. * It uses a {@code Transformer} to extract the iterators and elements.
* Its main benefit is that no intermediate {@code List} is created. * Its main benefit is that no intermediate {@code List} is created.
* </p>
* <p> * <p>
* For example, consider an object graph: * For example, consider an object graph:
* </p>
* <pre> * <pre>
* |- Branch -- Leaf * |- Branch -- Leaf
* | \- Leaf * | \- Leaf
@ -43,8 +45,10 @@ import org.apache.commons.collections4.Transformer;
* |- Tree | /- Leaf * |- Tree | /- Leaf
* |- Branch -- Leaf * |- Branch -- Leaf
* |- Branch -- Leaf</pre> * |- Branch -- Leaf</pre>
* <p>
* The following {@code Transformer}, used in this class, will extract all * The following {@code Transformer}, used in this class, will extract all
* the Leaf objects without creating a combined intermediate list: * the Leaf objects without creating a combined intermediate list:
* </p>
* <pre> * <pre>
* public Object transform(Object input) { * public Object transform(Object input) {
* if (input instanceof Forest) { * if (input instanceof Forest) {
@ -67,9 +71,11 @@ import org.apache.commons.collections4.Transformer;
* either an iterator or an object. If the object is an Iterator, the next element * either an iterator or an object. If the object is an Iterator, the next element
* from that iterator is obtained and the process repeats. If the element is an object * from that iterator is obtained and the process repeats. If the element is an object
* it is returned. * it is returned.
* </p>
* <p> * <p>
* Under many circumstances, linking Iterators together in this manner is * Under many circumstances, linking Iterators together in this manner is
* more efficient (and convenient) than using nested for loops to extract a list. * more efficient (and convenient) than using nested for loops to extract a list.
* </p>
* *
* @param <E> the type of elements returned by this iterator. * @param <E> the type of elements returned by this iterator.
* @since 3.1 * @since 3.1
@ -118,6 +124,7 @@ public class ObjectGraphIterator<E> implements Iterator<E> {
* be used to iterate over nested iterators. That is to say that the iterator * be used to iterate over nested iterators. That is to say that the iterator
* passed in here contains other iterators, which may in turn contain further * passed in here contains other iterators, which may in turn contain further
* iterators. * iterators.
* </p>
* *
* @param rootIterator the root iterator, null will result in an empty iterator * @param rootIterator the root iterator, null will result in an empty iterator
*/ */
@ -208,6 +215,7 @@ public class ObjectGraphIterator<E> implements Iterator<E> {
* This method calls remove() on the underlying Iterator, and it may * This method calls remove() on the underlying Iterator, and it may
* throw an UnsupportedOperationException if the underlying Iterator * throw an UnsupportedOperationException if the underlying Iterator
* does not support this method. * does not support this method.
* </p>
* *
* @throws UnsupportedOperationException * @throws UnsupportedOperationException
* if the remove operator is not supported by the underlying Iterator * if the remove operator is not supported by the underlying Iterator

View File

@ -26,6 +26,7 @@ import java.util.Objects;
* The decorator supports the removal operation, but an {@link IllegalStateException} * The decorator supports the removal operation, but an {@link IllegalStateException}
* will be thrown if {@link #remove()} is called directly after a call to * will be thrown if {@link #remove()} is called directly after a call to
* {@link #peek()} or {@link #element()}. * {@link #peek()} or {@link #element()}.
* </p>
* *
* @param <E> the type of elements returned by this iterator. * @param <E> the type of elements returned by this iterator.
* @since 4.0 * @since 4.0
@ -36,6 +37,7 @@ public class PeekingIterator<E> implements Iterator<E> {
* Decorates the specified iterator to support one-element lookahead. * Decorates the specified iterator to support one-element lookahead.
* <p> * <p>
* If the iterator is already a {@link PeekingIterator} it is returned directly. * If the iterator is already a {@link PeekingIterator} it is returned directly.
* </p>
* *
* @param <E> the element type * @param <E> the element type
* @param iterator the iterator to decorate * @param iterator the iterator to decorate
@ -128,9 +130,11 @@ public class PeekingIterator<E> implements Iterator<E> {
* <p> * <p>
* Note: this method does not throw a {@link NoSuchElementException} if the iterator * Note: this method does not throw a {@link NoSuchElementException} if the iterator
* is already exhausted. If you want such a behavior, use {@link #element()} instead. * is already exhausted. If you want such a behavior, use {@link #element()} instead.
* </p>
* <p> * <p>
* The rationale behind this is to follow the {@link java.util.Queue} interface * The rationale behind this is to follow the {@link java.util.Queue} interface
* which uses the same terminology. * which uses the same terminology.
* </p>
* *
* @return the next element from the iterator * @return the next element from the iterator
*/ */

View File

@ -33,9 +33,11 @@ import java.util.Objects;
* The iterator will return exactly n! permutations of the input collection. * The iterator will return exactly n! permutations of the input collection.
* The {@code remove()} operation is not supported, and will throw an * The {@code remove()} operation is not supported, and will throw an
* {@code UnsupportedOperationException}. * {@code UnsupportedOperationException}.
* </p>
* <p> * <p>
* NOTE: in case an empty collection is provided, the iterator will * NOTE: in case an empty collection is provided, the iterator will
* return exactly one empty list as result, as 0! = 1. * return exactly one empty list as result, as 0! = 1.
* </p>
* *
* @param <E> the type of the objects being permuted * @param <E> the type of the objects being permuted
* *

View File

@ -26,9 +26,11 @@ import java.util.Objects;
* <p> * <p>
* The decorator stores the pushed back elements in a LIFO manner: the last element * The decorator stores the pushed back elements in a LIFO manner: the last element
* that has been pushed back, will be returned as the next element in a call to {@link #next()}. * that has been pushed back, will be returned as the next element in a call to {@link #next()}.
* </p>
* <p> * <p>
* The decorator does not support the removal operation. Any call to {@link #remove()} will * The decorator does not support the removal operation. Any call to {@link #remove()} will
* result in an {@link UnsupportedOperationException}. * result in an {@link UnsupportedOperationException}.
* </p>
* *
* @param <E> the type of elements returned by this iterator. * @param <E> the type of elements returned by this iterator.
* @since 4.0 * @since 4.0
@ -39,6 +41,7 @@ public class PushbackIterator<E> implements Iterator<E> {
* Decorates the specified iterator to support one-element lookahead. * Decorates the specified iterator to support one-element lookahead.
* <p> * <p>
* If the iterator is already a {@link PushbackIterator} it is returned directly. * If the iterator is already a {@link PushbackIterator} it is returned directly.
* </p>
* *
* @param <E> the element type * @param <E> the element type
* @param iterator the iterator to decorate * @param iterator the iterator to decorate
@ -84,6 +87,7 @@ public class PushbackIterator<E> implements Iterator<E> {
* Push back the given element to the iterator. * Push back the given element to the iterator.
* <p> * <p>
* Calling {@link #next()} immediately afterwards will return exactly this element. * Calling {@link #next()} immediately afterwards will return exactly this element.
* </p>
* *
* @param item the element to push back to the iterator * @param item the element to push back to the iterator
*/ */

View File

@ -33,6 +33,7 @@ import org.apache.commons.collections4.ResettableListIterator;
* However, the {@code nextIndex()} method returns the correct * However, the {@code nextIndex()} method returns the correct
* index in the list, thus it starts high and reduces as the iteration * index in the list, thus it starts high and reduces as the iteration
* continues. The previous methods work similarly. * continues. The previous methods work similarly.
* </p>
* *
* @param <E> the type of elements returned by this iterator. * @param <E> the type of elements returned by this iterator.
* @since 3.2 * @since 3.2