Class LimitingDoubleIterator

java.lang.Object
com.github.tommyettinger.ds.support.util.LimitingDoubleIterator
All Implemented Interfaces:
DoubleIterator, Iterator<Double>

public class LimitingDoubleIterator extends Object implements DoubleIterator
Wraps an Iterator so that it only returns at most a specific amount of items (defined by calls to 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 Details

    • iterator

      public DoubleIterator iterator
    • limit

      protected int limit
    • remaining

      protected int remaining
  • Constructor Details

    • LimitingDoubleIterator

      public LimitingDoubleIterator()
    • LimitingDoubleIterator

      public LimitingDoubleIterator(DoubleIterator iterator, int limit)
  • Method Details