Packagecom.threerings.util
Classpublic class RingBuffer



Public Properties
 PropertyDefined by
  capacity : uint
Returns the capacity of the RingBuffer.
RingBuffer
  empty : Boolean
[read-only] Returns true if the RingBuffer contains 0 elements.
RingBuffer
  length : uint
[read-only] Returns the number of elements currently stored in the RingBuffer.
RingBuffer
Protected Properties
 PropertyDefined by
  _array : Array
RingBuffer
  _capacity : uint
RingBuffer
  _firstIndex : uint
RingBuffer
  _length : uint
RingBuffer
Public Methods
 MethodDefined by
  
RingBuffer(capacity:uint = 1)
Creates a new RingBuffer with the specified capacity.
RingBuffer
  
at(index:uint):*
Returns the element at the specified index.
RingBuffer
  
clear():void
Removes all elements from the RingBuffer.
RingBuffer
  
every(callback:Function, thisObject:* = null):Boolean
Executes a test function on each item in the ring buffer until an item is reached that returns false for the specified function.
RingBuffer
  
forEach(callback:Function, thisObject:* = null):void
Executes a function on each item in the ring buffer.
RingBuffer
  
indexOf(searchElement:*, fromIndex:int = 0):int
Searches for an item in the ring buffer by using strict equality (===) and returns the index position of the item, or -1 if the item is not found.
RingBuffer
  
pop():*
Removes the last element from the RingBuffer and returns it.
RingBuffer
  
push(... args):uint
Adds the specified elements to the back of the RingBuffer.
RingBuffer
  
shift():*
Removes the first element from the RingBuffer and returns it.
RingBuffer
  
unshift(... args):uint
Adds the specified elements to the front of the RingBuffer.
RingBuffer
Property detail
_arrayproperty
protected var _array:Array
_capacityproperty 
protected var _capacity:uint
capacityproperty 
capacity:uint  [read-write]

Returns the capacity of the RingBuffer.

Implementation
    public function get capacity():uint
    public function set capacity(value:uint):void
emptyproperty 
empty:Boolean  [read-only]

Returns true if the RingBuffer contains 0 elements.

Implementation
    public function get empty():Boolean
_firstIndexproperty 
protected var _firstIndex:uint
_lengthproperty 
protected var _length:uint
lengthproperty 
length:uint  [read-only]

Returns the number of elements currently stored in the RingBuffer.

Implementation
    public function get length():uint
Constructor detail
RingBuffer()constructor
public function RingBuffer(capacity:uint = 1)

Creates a new RingBuffer with the specified capacity.

Parameters
capacity:uint (default = 1)
Method detail
at()method
public function at(index:uint):*

Returns the element at the specified index. If index >= length, at() will return undefined.

Parameters
index:uint

Returns
*
clear()method 
public function clear():void

Removes all elements from the RingBuffer.

every()method 
public function every(callback:Function, thisObject:* = null):Boolean

Executes a test function on each item in the ring buffer until an item is reached that returns false for the specified function. Returns a Boolean value of true if all items in the buffer return true for the specified function; otherwise, false.

Parameters
callback:Function
 
thisObject:* (default = null)

Returns
Boolean
forEach()method 
public function forEach(callback:Function, thisObject:* = null):void

Executes a function on each item in the ring buffer.

Parameters
callback:Function
 
thisObject:* (default = null)
indexOf()method 
public function indexOf(searchElement:*, fromIndex:int = 0):int

Searches for an item in the ring buffer by using strict equality (===) and returns the index position of the item, or -1 if the item is not found.

Parameters
searchElement:*
 
fromIndex:int (default = 0)

Returns
int
pop()method 
public function pop():*

Removes the last element from the RingBuffer and returns it. If the RingBuffer is empty, pop() will return undefined.

Returns
*
push()method 
public function push(... args):uint

Adds the specified elements to the back of the RingBuffer. If the RingBuffer's length is equal to its capacity, this will cause a elements to be removed from the front of the RingBuffer. Returns the new length of the RingBuffer.

Parameters
... args

Returns
uint
shift()method 
public function shift():*

Removes the first element from the RingBuffer and returns it. If the RingBuffer is empty, shift() will return undefined.

Returns
*
unshift()method 
public function unshift(... args):uint

Adds the specified elements to the front of the RingBuffer. If the RingBuffer's length is equal to its capacity, this will cause elements to be removed from the back of the RingBuffer. Returns the new length of the RingBuffer.

Parameters
... args

Returns
uint