Defines a templated (generic) class for a double-ended queue of things. This code is a modifiation from Arduino-Queue by Steven de Salas. See his well written readme for more information.
Tested on Arduino Uno and ESP32
Creates a double-ended queue of a generic type T
with a maximum queue size. If maxlength
is not defined it will default to 256.
NOTE: If the queue grows to maxlength
items (and you dont take them out) any additional items added will drop out of the queue.
Please bear this in mind when defining maxlength so it is a reasonable balance between RAM usage and functional usefulness.
Adds a generic item (of T
type) at the back of the queue.
Adds a generic item (of T
type) at the front of the queue.
Gets a generic item (of T
type) from the back of the queue.
Gets a generic item (of T
type) from the front of the queue.
Same as .pop_back() but keeps the item in the queue.
Same as .pop_front() but keeps the item in the queue.
Get the item at index i
in the queue. The item will be kept in the queue. If the index is out of bound, an empty item is returned.
Set the item at index i
in the queue. If the index is out of bound, nothing happens.
Gets the current number of elements in the queue.
Clears the queue but does not free memory used to store data.
Returns items in the queue as an array.
Gets the current position in the front of the queue. Used for testing queue logic.
Gets the current position at the back of the queue. Used for testing queue logic.
Returns all values from data allocated memory. Used for testing queue logic.