Legal Notice, Privacy Policy

Impressum, Datenschutzerklärung

Cerberus X Documentation

Class RingBuffer

A ringbuffer is a circular FIFO buffer that wraps a DataBuffer. More...

Declarations

Constructors
New ( capacity:Int, dynamic:Bool ) Creates a new ringbuffer with the given capacity.
Methods
CanGet : Int () Returns the number of bytes that can be read from the buffer using Get.
CanPut : Int () Returns the number of bytes that can be written to the buffer using Put.
Capacity : Int () Returns the size of the buffer in bytes, ie: CanGet+CanPut.
Clear : Void () Empties the buffer.
Get : Int ( data:DataBuffer, offset:Int, count:Int ) Removes count bytes from the start of the ringbuffer and copies them to data/offset.
IsEmpty : Bool () Returns true if the buffer is empty, ie: CanGet=0.
IsFull : Bool () Return true if the buffer is full, ie: CanPut=0.
Put : Int ( data:DataBuffer, offset:Int, count:Int ) Copies count bytes from data/offset and adds them to the end of the ringbuffer.

Detailed Discussion

A ringbuffer is a circular FIFO buffer that wraps a DataBuffer.

Data can be added to the end of the buffer using Put, and removed from the start of the buffer using Get.

A ringbuffer can also dynamically resize itself as necessary so that Put always succeeds.


Constructors Documentation

Method New ( capacity:Int, dynamic:Bool )

Creates a new ringbuffer with the given capacity. This is the number of bytes the buffer can store.

If dynamic is true, the ringbuffer will grow as necessary so that Put always succeeds.


Methods Documentation

Method CanGet : Int ()

Returns the number of bytes that can be read from the buffer using Get.

Method CanPut : Int ()

Returns the number of bytes that can be written to the buffer using Put.

Method Capacity : Int ()

Returns the size of the buffer in bytes, ie: CanGet+CanPut.

Method Clear : Void ()

Empties the buffer.

Method Get : Int ( data:DataBuffer, offset:Int, count:Int )

Removes count bytes from the start of the ringbuffer and copies them to data/offset.

Returns the number of bytes actually transferred.

Method IsEmpty : Bool ()

Returns true if the buffer is empty, ie: CanGet=0.

Method IsFull : Bool ()

Return true if the buffer is full, ie: CanPut=0.

Method Put : Int ( data:DataBuffer, offset:Int, count:Int )

Copies count bytes from data/offset and adds them to the end of the ringbuffer.

Returns the number of bytes actually transferred.

If the buffer is dynamic, this method will reallocate the internal databuffer as necessary so that all count bytes are always added.