modm API documentation
|
Double ended queue. More...
#include <modm/container/deque.hpp>
Classes | |
class | const_iterator |
Bidirectional const iterator More... | |
Public Typedefs | |
using | Index = std::conditional_t< (N >=255), uint_fast16_t, uint_fast8_t > |
using | Size = Index |
Public Member Functions | |
bool | isEmpty () const |
bool | isNotEmpty () const |
bool | isFull () const |
bool | isNotFull () const |
Size | getSize () const |
Size | getMaxSize () const |
void | clear () |
Clear the container. More... | |
T & | getFront () |
const T & | getFront () const |
T & | get (Index n) |
Get item at specified index. More... | |
const T & | get (Index n) const |
T & | operator[] (Index n) |
Get item at specified index. More... | |
const T & | operator[] (Index n) const |
T & | rget (Index n) |
Get item at specified index. More... | |
const T & | rget (Index n) const |
T & | getBack () |
const T & | getBack () const |
bool | append (const T &value) |
void | appendOverwrite (const T &value) |
Append an item to the back of the deque overwriting existing items. More... | |
bool | prepend (const T &value) |
void | prependOverwrite (const T &value) |
Prepend an item to the front of the deque overwriting existing items. More... | |
void | removeBack () |
void | removeFront () |
const_iterator | begin () const |
const_iterator | end () const |
Friends | |
class | const_iterator |
Double ended queue.
Internally organized as a ring buffer.
* tail --\ /-- head * | | * +------+------+---- ----+------+------+ * 0 | | data | ... | data | | N-1 * +------+------+---- ----+------+------+ * | | | | * prepend --/ | | \-- append * | | * getFront --/ \-- getBack *
T | Type of the elements |
N | Size of the queue |
Up to a size of 254 small index variables with 8-bits are used, after this they are switched to 16-bit.
void modm::BoundedDeque< T, N >::appendOverwrite | ( | const T & | value | ) |
Append an item to the back of the deque overwriting existing items.
This method, in contrast to append()
, overwrites existing items in the deque if it is full. When an item is appended to the already full deque, the front item is removed to use its space for the new item, which is inserted after back.
void modm::BoundedDeque< T, N >::clear | ( | ) |
Clear the container.
|
inline |
Get item at specified index.
Returns a reference to the item at index n
, counting 0-indexed from Front to Back, which is the same order in that the items were appended and the iterator addresses them.
n
is a valid index: 0 <= n < size. Other indexes will cause undefined behaviour.
|
inline |
Get item at specified index.
Returns a reference to the item at index n
, counting 0-indexed from Front to Back.
n
is a valid index: 0 <= n < size. Other indexes will cause undefined behaviour. void modm::BoundedDeque< T, N >::prependOverwrite | ( | const T & | value | ) |
Prepend an item to the front of the deque overwriting existing items.
This method, in contrast to prepend()
, overwrites existing items in the deque if it is full. When an item is prepended to the already full deque, the back item is removed to use its space for the new item, which is inserted at front.
|
inline |
Get item at specified index.
Returns a reference to the item at index n
. The items are indexed in reverse (Back to Front), which is their order when they have been prepended.
n
is a valid index: 0 <= n < size. Other indexes will cause undefined behaviour.