Class Buffer<T>

  • Type Parameters:
    T - The type held in this buffer
    All Implemented Interfaces:
    java.lang.Comparable<Buffer<T>>
    Direct Known Subclasses:
    StrideTracker

    public abstract class Buffer<T>
    extends java.lang.Object
    implements java.lang.Comparable<Buffer<T>>
    This is a lightweight buffer implementation that allows for buffer flipping and callbacks when the buffer is full.
    • Constructor Summary

      Constructors 
      Constructor Description
      Buffer​(java.lang.Class<T[]> clazz, int size)  
    • Method Summary

      Modifier and Type Method Description
      protected abstract int compare​(T one, T other)  
      int compareTo​(Buffer<T> other)  
      Buffer<T> flip()  
      T get()  
      protected void onFull()  
      int position()  
      Buffer<T> position​(int position)  
      Buffer<T> put​(T element)  
      int remaining()  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Buffer

        public Buffer​(java.lang.Class<T[]> clazz,
                      int size)
    • Method Detail

      • onFull

        protected void onFull()
      • compare

        protected abstract int compare​(T one,
                                       T other)
      • position

        public int position()
      • position

        public Buffer<T> position​(int position)
      • remaining

        public int remaining()
      • put

        public Buffer<T> put​(T element)
      • get

        public T get()
      • compareTo

        public int compareTo​(Buffer<T> other)
        Specified by:
        compareTo in interface java.lang.Comparable<T>
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object