类 FastQueue<T>

  • 直接已知子类:
    LookaheadStream

    public class FastQueue<T>
    extends java.lang.Object
    A queue that can dequeue and get(i) in O(1) and grow arbitrarily large. A linked list is fast at dequeue but slow at get(i). An array is the reverse. This is O(1) for both operations. List grows until you dequeue last element at end of buffer. Then it resets to start filling at 0 again. If adds/removes are balanced, the buffer will not grow too large. No iterator stuff as that's not how we'll use it.
    • 字段概要

      字段 
      修饰符和类型 字段 说明
      protected java.util.List<T> data
      dynamically-sized buffer of elements
      protected int p
      index of next element to fill
      protected int range  
    • 构造器概要

      构造器 
      构造器 说明
      FastQueue()  
    • 方法概要

      所有方法 实例方法 具体方法 
      修饰符和类型 方法 说明
      void add​(T o)  
      void clear()  
      T elementAt​(int i)
      Return element i elements ahead of current element.
      T head()  
      int range()  
      T remove()
      Get and remove first element in queue
      void reset()  
      int size()  
      java.lang.String toString()
      Return string of current buffer contents; non-destructive
      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • 字段详细资料

      • data

        protected java.util.List<T> data
        dynamically-sized buffer of elements
      • p

        protected int p
        index of next element to fill
      • range

        protected int range
    • 构造器详细资料

      • FastQueue

        public FastQueue()
    • 方法详细资料

      • reset

        public void reset()
      • clear

        public void clear()
      • remove

        public T remove()
        Get and remove first element in queue
      • add

        public void add​(T o)
      • size

        public int size()
      • range

        public int range()
      • head

        public T head()
      • elementAt

        public T elementAt​(int i)
        Return element i elements ahead of current element. i==0 gets current element. This is not an absolute index into data since p defines the start of the real list.
      • toString

        public java.lang.String toString()
        Return string of current buffer contents; non-destructive
        覆盖:
        toString 在类中 java.lang.Object