Class LimitingBooleanIterator

java.lang.Object
com.github.tommyettinger.ds.support.util.LimitingBooleanIterator
All Implemented Interfaces:
BooleanIterator, Iterator<Boolean>

public class LimitingBooleanIterator extends Object implements BooleanIterator
Wraps an Iterator so that it only returns at most a specific amount of items (defined by calls to nextBoolean(). 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(BooleanIterator, int), and can also just change the Iterator with set(BooleanIterator).
  • Field Details

    • iterator

      public BooleanIterator iterator
    • limit

      protected int limit
    • remaining

      protected int remaining
  • Constructor Details

    • LimitingBooleanIterator

      public LimitingBooleanIterator()
    • LimitingBooleanIterator

      public LimitingBooleanIterator(BooleanIterator iterator, int limit)
  • Method Details