com.apamax.containers
Event FixedSizeCircularBuffer


A fixed-sized circular buffer object.

Once the buffer is full, adding another value removes the oldest one in the buffer.
Action summary
 integercapacity()

Return the capacity of this circular buffer.
 voidclear()

Remove all the values in the buffer.
 com.apamax.containers.FixedSizeCircularBufferstatic create(integer size)

Create an empty buffer of a particular size.
 booleanempty()

Returns true if the buffer is empty.
 booleanfull()

Returns true if the buffer is full (size() == capacity()).
 anyget(integer offs)

Return the item currently at the given position in the buffer.
 sequence<any>getData()

Return the underlying sequence containing the circular buffer in order. This is returned by reference. You should not modify the return value, only clone it or iterate over it.
 voidpush(any val)

Push a value onto the buffer. If the buffer is full, removes the oldest value.
 integersize()

Return the number of values in the buffer.
 
Action detail

capacity

integer capacity()
Return the capacity of this circular buffer.

clear

void clear()
Remove all the values in the buffer.

create

com.apamax.containers.FixedSizeCircularBuffer static create(integer size)
Create an empty buffer of a particular size.
Parameters:
size - The maximum capacity of the buffer.

empty

boolean empty()
Returns true if the buffer is empty.

full

boolean full()
Returns true if the buffer is full (size() == capacity()).

get

any get(integer offs)
Return the item currently at the given position in the buffer.
Parameters:
offs - The offset into the buffer, with 0 being the oldest and capacity-1 being the most recent.

getData

sequence<any> getData()
Return the underlying sequence containing the circular buffer in order. This is returned by reference. You should not modify the return value, only clone it or iterate over it.

push

void push(any val)
Push a value onto the buffer. If the buffer is full, removes the oldest value.
Parameters:
val - The value to add to the buffer.

size

integer size()
Return the number of values in the buffer.