CircularBuffer

org.eso.ias.utils.CircularBuffer
See theCircularBuffer companion object
class CircularBuffer[T](maxBufferSize: Int)(implicit evidence$1: ClassTag[T])

A circular buffer of a fixed size backed by an Array.

The buffer does not allow to store null items.

The position to read and write elements in the buffer is stored in the readPointer and writePointer pointers (i.e. indexes of the array) to avoid moving objects from one position to another in the buffer.

The CircularBuffer is thread safe.

Type parameters

T

the type of the objects stored in the buffer

Value parameters

maxBufferSize

The max number of items to store in the circular buffer

Attributes

Since

13.0

Companion
object
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def clear(): Unit

Remove all the elements from the buffer

Remove all the elements from the buffer

Attributes

def dump(): Unit

Debug method to dump the content of the buffer and the value the indexes in the array stored by the pointers

Debug method to dump the content of the buffer and the value the indexes in the array stored by the pointers

Attributes

def get(): Option[T]

Attributes

Returns

the oldest item in the buffer or None if the buffer is empty

def getAll(): List[T]

Attributes

Returns

the items in the buffer

def isEmpty(): Boolean

True if the buffer is empty; false otherwise

True if the buffer is empty; false otherwise

Attributes

def length: Int

Attributes

Returns

the length of the buffer i.e. the max number of items that the buffer can store

def put(item: T): Unit

Put a new object in the circular buffer deleting the oldest one if the buffer is full

Put a new object in the circular buffer deleting the oldest one if the buffer is full

Value parameters

item

the object to add

Attributes

def putAll(items: List[T]): Unit

Put all the passed items in the buffer

Put all the passed items in the buffer

Value parameters

items

the items to put in the buffer

Attributes

def size: Int

Attributes

Returns

the number of objects in the circular buffer