CircularBuffer<T>

Type parameters

Name
T

Constructors

constructor

+ new CircularBuffer<T>(capacity: number, evictedCallback?: (element: T) => void): CircularBuffer<T>

Type parameters:

Name
T

Parameters:

NameType
capacitynumber
evictedCallback?(element: T) => void

Returns: CircularBuffer<T>

Properties

_evictedCallback

Readonly _evictedCallback: (element: T) => void

Type declaration:

▸ (element: T): void

Parameters:

NameType
elementT

Returns: void

Methods

capacity

capacity(): number

Returns: number


data

data(): (undefined | T)[]

Returns: (undefined | T)[]


isEmpty

isEmpty(): boolean

Returns: boolean


isFull

isFull(): boolean

Returns: boolean


pushFront

pushFront(element: T): boolean

Parameters:

NameType
elementT

Returns: boolean


resetData

resetData(newData: T[], pushFrontLike?: boolean): void

Resets currently stored data with provided array, regarding to current capacity. Note: current capacity will not be changed Note: all previous data will be erased, but the 'evictedCallback()' function will not be called for erased items

Parameters:

NameTypeDefault valueDescription
newDataT[]-new data to store
pushFrontLikebooleantrueif true, the data will be set in the same order as it would be pushed by @method pushFront, otherwise, the data will be pushed as it would be done by @method pushBack

Returns: void


size

size(): number

Returns: number


toArray

toArray(): T[]

Returns: T[]

Found a mistake? Email us, and we'll send you a free t-shirt!

Enroll in beta

Request invite to our private Beta program for developers to join the waitlist. No spam, we promise.