CircularBuffer<T>
Type parameters
Name |
---|
T |
Constructors
constructor
+ new CircularBuffer<T>(capacity
: number, evictedCallback?
: (element
: T) => void): CircularBuffer<T>
Type parameters:
Name |
---|
T |
Parameters:
Name | Type |
---|---|
capacity | number |
evictedCallback? | (element : T) => void |
Returns: CircularBuffer<T>
Properties
_evictedCallback
• Readonly
_evictedCallback: (element
: T) => void
Type declaration:
▸ (element
: T): void
Parameters:
Name | Type |
---|---|
element | T |
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:
Name | Type |
---|---|
element | T |
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:
Name | Type | Default value | Description |
---|---|---|---|
newData | T[] | - | new data to store |
pushFrontLike | boolean | true | if 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[]