Class RollingBuffer<T extends RollingBuffer.Resettable>

java.lang.Object
org.apache.lucene.util.RollingBuffer<T>
Direct Known Subclasses:
TokenStreamToAutomaton.Positions

public abstract class RollingBuffer<T extends RollingBuffer.Resettable> extends Object
Acts like forever growing T[], but internally uses a circular buffer to reuse instances of T.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
    Implement to reset an instance
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private T[]
     
    private int
     
    private int
     
    private int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    freeBefore(int pos)
     
    get(int pos)
    Get T instance for this absolute position; this is allowed to be arbitrarily far "in the future" but cannot be before the last freeBefore.
    int
    Returns how many active positions are in the buffer.
    private int
    getIndex(int pos)
     
    int
    Returns the maximum position looked up, or -1 if no position has been looked up since reset/init.
    private boolean
    inBounds(int pos)
     
    protected abstract T
     
    void
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • buffer

      private T extends RollingBuffer.Resettable[] buffer
    • nextWrite

      private int nextWrite
    • nextPos

      private int nextPos
    • count

      private int count
  • Constructor Details

    • RollingBuffer

      public RollingBuffer()
  • Method Details

    • newInstance

      protected abstract T newInstance()
    • reset

      public void reset()
    • inBounds

      private boolean inBounds(int pos)
    • getIndex

      private int getIndex(int pos)
    • get

      public T get(int pos)
      Get T instance for this absolute position; this is allowed to be arbitrarily far "in the future" but cannot be before the last freeBefore.
    • getMaxPos

      public int getMaxPos()
      Returns the maximum position looked up, or -1 if no position has been looked up since reset/init.
    • getBufferSize

      public int getBufferSize()
      Returns how many active positions are in the buffer.
    • freeBefore

      public void freeBefore(int pos)