CircularVector class

Circular vector uses a single buffer to capture a stream of values overwriting the oldest value on add.

This supports adding to the ‘head’ or ’tail’ and will grow the buffer to match a configured capacity.

Signature

  1. export declare class CircularVector<T = any> extends FunctionalVector<T> implements MutableVector<T>

Import

  1. import { CircularVector } from '@grafana/data';

Constructors

ConstructorModifiersDescription
constructor(options)Constructs a new instance of the CircularVector class

Properties

PropertyModifiersTypeDescription
add(value: T) => voidAdd the value to the buffer
lengthnumber

Methods

MethodModifiersDescription
get(index)
reverse()
set(index, value)
setAppendMode(mode)
setCapacity(v)
toArray()
toJSON()

constructor(options)

Constructs a new instance of the CircularVector class

Signature

  1. constructor(options: CircularOptions<T>);

Parameters

ParameterTypeDescription
optionsCircularOptions<T>

add property

Add the value to the buffer

Signature

  1. add: (value: T) => void;

length property

Signature

  1. get length(): number;

get method

Signature

  1. get(index: number): T;

Parameters

ParameterTypeDescription
indexnumber

Returns:

T

reverse method

Signature

  1. reverse(): void;

Returns:

void

set method

Signature

  1. set(index: number, value: T): void;

Parameters

ParameterTypeDescription
indexnumber
valueT

Returns:

void

setAppendMode method

Signature

  1. setAppendMode(mode: 'head' | 'tail'): void;

Parameters

ParameterTypeDescription
mode‘head’ | ’tail’

Returns:

void

setCapacity method

Signature

  1. setCapacity(v: number): void;

Parameters

ParameterTypeDescription
vnumber

Returns:

void

toArray method

Signature

  1. toArray(): T[];

Returns:

T[]

toJSON method

Signature

  1. toJSON(): T[];

Returns:

T[]