Class BooleanBigListIterators.AbstractIndexBasedBigIterator

java.lang.Object
it.unimi.dsi.fastutil.booleans.AbstractBooleanIterator
it.unimi.dsi.fastutil.booleans.BooleanBigListIterators.AbstractIndexBasedBigIterator
All Implemented Interfaces:
it.unimi.dsi.fastutil.booleans.BooleanIterator, Iterator<Boolean>, PrimitiveIterator<Boolean,it.unimi.dsi.fastutil.booleans.BooleanConsumer>
Direct Known Subclasses:
BooleanBigListIterators.AbstractIndexBasedBigListIterator
Enclosing class:
BooleanBigListIterators

public abstract static class BooleanBigListIterators.AbstractIndexBasedBigIterator extends it.unimi.dsi.fastutil.booleans.AbstractBooleanIterator
A skeletal implementation for an iterator backed by an index based data store. High performance concrete implementations (like the main Iterator of BigArrayBigList) generally should avoid using this and just implement the interface directly, but should be decent for less performance critical implementations.

As the abstract methods in this class are used in inner loops, it is generally a good idea to override the class as final as to encourage the JVM to inline them (or alternatively, override the abstract methods as final).

  • Nested Class Summary

    Nested classes/interfaces inherited from interface java.util.PrimitiveIterator

    PrimitiveIterator.OfDouble, PrimitiveIterator.OfInt, PrimitiveIterator.OfLong
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected long
    The last returned index by a call to BooleanIterator.next() or, if a list-iterator,
    invalid @link
    {@link java.util.ListIterator#previous().
    Is -1 if no such call has occurred or a mutation has occurred through this iterator and no advancement has been done.
    protected final long
    The minimum pos can be, and is the logical start of the "range".
    protected long
    The current position index, the index of the item to be returned after the next call to BooleanIterator.next().
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    AbstractIndexBasedBigIterator(long minPos, long initialPos)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    forEachRemaining(it.unimi.dsi.fastutil.booleans.BooleanConsumer action)
     
    protected abstract boolean
    get(long location)
    Get the item corresponding to the given index location.
    protected abstract long
    The maximum pos can be, and is the logical end of the "range".
    boolean
     
    boolean
     
    void
     
    protected abstract void
    remove(long location)
    Remove the item at the given index.
    int
    skip(int n)
     
    long
    skip(long n)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface it.unimi.dsi.fastutil.booleans.BooleanIterator

    forEachRemaining, next
  • Field Details

    • minPos

      protected final long minPos
      The minimum pos can be, and is the logical start of the "range". Usually set to the initialPos unless it is a ListIterator, in which case it can vary. There isn't any way for a range to shift its beginning like the end can (through remove(long)), so this is final.
    • pos

      protected long pos
      The current position index, the index of the item to be returned after the next call to BooleanIterator.next().

      This value will be between minPos and getMaxPos() (exclusive) (on a best effort, so concurrent structural modifications outside this iterator may cause this to be violated, but that usually invalidates iterators anyways). Thus pos being minPos + 2 would mean BooleanIterator.next() was called twice and the next call will return the third element of this iterator.

    • lastReturned

      protected long lastReturned
      The last returned index by a call to BooleanIterator.next() or, if a list-iterator,
      invalid @link
      {@link java.util.ListIterator#previous().
      Is -1 if no such call has occurred or a mutation has occurred through this iterator and no advancement has been done.
  • Constructor Details

    • AbstractIndexBasedBigIterator

      protected AbstractIndexBasedBigIterator(long minPos, long initialPos)
  • Method Details

    • get

      protected abstract boolean get(long location)
      Get the item corresponding to the given index location.

      Do not advance pos in this method; the default next method takes care of this.

      The location given will be between minPos and getMaxPos() (exclusive). Thus, a location of minPos + 2 would mean BooleanIterator.next() was called twice and this method should return what the next call to BooleanIterator.next() should return.

    • remove

      protected abstract void remove(long location)
      Remove the item at the given index.

      Do not modify pos in this method; the default #remove() method takes care of this.

      This method should also do what is needed to track the change to the getMaxPos(). Usually this is accomplished by having this method call the parent

      invalid reference
      Collection
      's appropriate remove method, and having getMaxPos() track the parent collection's size64().
    • getMaxPos

      protected abstract long getMaxPos()
      The maximum pos can be, and is the logical end of the "range".

      If pos is equal to the return of this method, this means the last element has been returned and the next call to BooleanIterator.next() will throw.

      Usually set return the parent collection's size64(), but does not have to be (for example, sublists and subranges).

    • hasNext

      public boolean hasNext()
    • nextBoolean

      public boolean nextBoolean()
    • remove

      public void remove()
    • forEachRemaining

      public void forEachRemaining(it.unimi.dsi.fastutil.booleans.BooleanConsumer action)
    • skip

      public long skip(long n)
    • skip

      public int skip(int n)