Circular buffer

ATTENTION. THIS CURRENTLY WORKS DIFFERENTLY FROM A CIRCULAR BUFFER ⚠️ READ ESPECIALLY pushFront, pushBack, popFront and popBack!

To quickly start with circular buffers:

  1. Find the Functions panel on the left-hand side of the screen.

  2. Expand Utilities and then Circular Buffer.

  3. Create a buffer instance with the create function.

  4. Expand the instance that appeared in the panel and get started with using the buffer.

Use the create and delete functions to manage the existing circular buffers. Existing buffers can be seen in the functions panel on the left under circular buffers. Yellow ones are uninstantiated and green ones are ready for use.

Creating a buffer

To create a circular buffer:

  1. Insert a new name in the yellow field.

  2. Insert a capacity in integer form in the second field.

  3. Click the trigger field to create an instance of the buffer

    • You should see the buffer in the functions panel go from yellow to green

Deleting a buffer

To delete a buffer:

  1. Insert the name of an existing buffer in the yellow field.

  2. Click the trigger field.

The instance in the functions panel will turn yellow again, until the yellow field of the create function is cleared, or the create function is deleted from the board.

Circular buffer functions

To utilize the circular buffer, you can find functions tied to each instance when you expand the instance with a click on the arrow in front of it.

Retrieving buffer size

getSize returns the amount of values currently saved inside the buffer.

Retrieving buffer capacity

getCapacity returns the maximum number of values storable in the buffer.

Retrieving buffer content

getBuffer returns the content of the circular buffer as an object.

Inserting value in front

pushFront inserts a new value at the front, pushing all other values back one slot. When the buffer is full, the values at the back get dropped.

Inserting value at the end

pushBack inserts a new value at the end of the currently existing values. When the buffer is full, new values are inserted at the end and old values get pushed one index to the front. The first entry is thereby deleted every time something is inserted into a full buffer with this function.

Retrieving first entry

With popFront you can get the first entry in the buffer returned. The entry is deleted upon triggering this function and all other entries move up one index.

Retrieving last entry

With popBack you can get the last entry in the buffer returned. The entry is deleted upon triggering this function.

Last updated