Class LimitingDoubleIterator
java.lang.Object
com.github.tommyettinger.ds.support.util.LimitingDoubleIterator
- All Implemented Interfaces:
DoubleIterator,Iterator<Double>
Wraps an Iterator so that it only returns at most a specific amount of items (defined by calls to
You can change the Iterator and limit at once using
nextDouble(). This can be useful to limit infinite Iterators so they only produce a finite amount of results.
This has undefined behavior if any items the Iterator could return are modified during iteration.
You can change the Iterator and limit at once using
set(DoubleIterator, int), and can also just
change the Iterator with set(DoubleIterator).-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanhasNext()doubleReturns the nextdoubleelement in the iteration.voidremove()voidset(DoubleIterator iterator) voidset(DoubleIterator iterator, int limit) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.github.tommyettinger.ds.support.util.DoubleIterator
forEachRemaining, nextMethods inherited from interface java.util.Iterator
forEachRemaining
-
Field Details
-
iterator
-
limit
protected int limit -
remaining
protected int remaining
-
-
Constructor Details
-
LimitingDoubleIterator
public LimitingDoubleIterator() -
LimitingDoubleIterator
-
-
Method Details
-
set
-
set
-
hasNext
public boolean hasNext() -
nextDouble
public double nextDouble()Description copied from interface:DoubleIteratorReturns the nextdoubleelement in the iteration.- Specified by:
nextDoublein interfaceDoubleIterator- Returns:
- the next
doubleelement in the iteration
-
remove
public void remove()
-