videolib.buffer.CircularBuffer

class CircularBuffer(buf_size)[source]

Bases: object

Class defining a circular buffer.

Parameters:

buf_size (int) – Size of the buffer

Methods

append

Append copy of item into circular buffer.

back

Get top element of circular buffer.

center

Get center element of circular buffer.

check_append

If buffer is empty, fill.

clear

Clear circular buffer.

fill

Clear buffer and fill with shallow copies of item.

front

Get top element of circular buffer.

isempty

Check if buffer is empty.

append(item)[source]

Append copy of item into circular buffer.

Parameters:

item (Any) – Item to be appended.

Return type:

None

back()[source]

Get top element of circular buffer.

Return type:

Any

center()[source]

Get center element of circular buffer.

Return type:

Any

check_append(item)[source]

If buffer is empty, fill. Else, append.

Parameters:

item (Any) – Item to be used to fill/append.

Return type:

None

clear()[source]

Clear circular buffer.

Return type:

None

fill(item)[source]

Clear buffer and fill with shallow copies of item.

Parameters:

item (Any) – Item to be used to fill.

Return type:

None

front()[source]

Get top element of circular buffer.

Return type:

Any

isempty()[source]

Check if buffer is empty.

Return type:

bool

Returns:

Flag denoting if buffer is empty.