Options
All
  • Public
  • Public/Protected
  • All
Menu

Class RingBuffer<T>

A simple ring buffer to store the last n values of the timer. The buffer works on a First-In-First-Out (FIFO) basis.

Type parameters

  • T

Hierarchy

  • RingBuffer

Index

Classes

Constructors

Properties

Accessors

Methods

Constructors

constructor

Properties

buffer

buffer: T[]

Readonly capacity

capacity: number

The buffer's capacity.

head

head: number

size

size: number

tail

tail: number

Accessors

bottom

  • get bottom(): T
  • Obtains the latest element (LIFO) without removing it. Throws an exception if a buffer is empty. Before calling this method, make sure that size > 0.

    Returns T

top

  • get top(): T
  • Obtains the oldest element (FIFO) without removing it. Throws an exception if a buffer is empty. Before calling this method, make sure that size > 0.

    Returns T

Methods

asArray

  • asArray(): T[]

clear

  • clear(): void

deq

  • deq(): T
  • Obtains the oldest element (FIFO). May throw an exception if a buffer underrun occurs. Before calling this method, make sure that size > 0.

    Returns T

enq

  • enq(...data: T[]): void

enqOne

  • enqOne(data: T): void

iterator

Generated using TypeDoc