Module org.jhotdraw8.collection
Class AbstractEnumerator<E>
java.lang.Object
java.util.Spliterators.AbstractSpliterator<E>
org.jhotdraw8.collection.enumerator.AbstractEnumerator<E>
- Type Parameters:
E- the element type
- All Implemented Interfaces:
Spliterator<E>,BareEnumerator<E>,Enumerator<E>
public abstract class AbstractEnumerator<E>
extends Spliterators.AbstractSpliterator<E>
implements Enumerator<E>
Abstract base classes for
Enumerators.
Subclasses should only implement the BareEnumerator.moveNext()
method and (optionally) the Spliterator.trySplit() method:
public boolean moveNext() {
if (...end not reached...) {
current = ...;
return true;
}
return false;
}
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.jhotdraw8.collection.enumerator.Enumerator
Enumerator.OfDouble, Enumerator.OfInt, Enumerator.OfLongNested classes/interfaces inherited from interface java.util.Spliterator
Spliterator.OfDouble, Spliterator.OfInt, Spliterator.OfLong, Spliterator.OfPrimitive<T,T_CONS, T_SPLITR extends Spliterator.OfPrimitive<T, T_CONS, T_SPLITR>> -
Field Summary
FieldsFields inherited from interface java.util.Spliterator
CONCURRENT, DISTINCT, IMMUTABLE, NONNULL, ORDERED, SIZED, SORTED, SUBSIZED -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractEnumerator(long est, int additionalCharacteristics) Creates a spliterator reporting the given estimated size and additionalCharacteristics. -
Method Summary
Methods inherited from class java.util.Spliterators.AbstractSpliterator
characteristics, estimateSize, trySplitMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.jhotdraw8.collection.enumerator.BareEnumerator
moveNextMethods inherited from interface org.jhotdraw8.collection.enumerator.Enumerator
tryAdvanceMethods inherited from interface java.util.Spliterator
characteristics, estimateSize, forEachRemaining, getComparator, getExactSizeIfKnown, hasCharacteristics, trySplit
-
Field Details
-
current
The current element of the enumerator.
-
-
Constructor Details
-
AbstractEnumerator
protected AbstractEnumerator(long est, int additionalCharacteristics) Creates a spliterator reporting the given estimated size and additionalCharacteristics.- Parameters:
est- the estimated size of this spliterator if known, otherwiseLong.MAX_VALUE.additionalCharacteristics- properties of this spliterator's source or elements. IfSIZEDis reported then this spliterator will additionally reportSUBSIZED.
-
-
Method Details
-
current
Gets the element in the collection at the current position of the enumerator.Current is undefined under any of the following conditions:
- The enumerator is positioned before the first element in the collection.
Immediately after the enumerator is created
BareEnumerator.moveNext()must be called to advance the enumerator to the first element of the collection before reading the value of Current. - The last call to
BareEnumerator.moveNext()returned false, which indicates the end of the collection. - The enumerator is invalidated due to changes made in the collection, such as adding, modifying, or deleting elements.
- Specified by:
currentin interfaceBareEnumerator<E>- Returns:
- current
- The enumerator is positioned before the first element in the collection.
Immediately after the enumerator is created
-