#include <stdint.h>Macros | |
| #define | DEFINE_DEQUE_TYPE(typename, value_type, max_size) |
| A new deque type definition. More... | |
| #define | DEFINE_DEQUE(typename, deque) |
| A predefined deque definition with no elements. More... | |
| #define | DEQUE_PUSH_BACK(deque, value) |
| Add data to the end of the deque. More... | |
| #define | DEQUE_PUSH_FRONT(deque, value) |
| Add data to the front of the deque. More... | |
| #define | DEQUE_FRONT(deque) |
| #define | DEQUE_BACK(deque) |
| #define | DEQUE_EMPTY(deque) |
| #define | DEQUE_POP_FRONT(deque) |
| Removes the first element. More... | |
| #define | DEQUE_POP_BACK(deque) |
| Removes the last element. More... | |
| #define | DEQUE_SIZE(deque) |
| #define | DEQUE_MAX_SIZE(deque) |
| #define | DEQUE_CLEAR(deque) |
| #define | DEQUE_FILL(deque, n, value) |
| #define | DEQUE_AT(deque, n) |
deque (usually pronounced like "deck") is an irregular acronym of double-ended deque. Double-ended queues are sequence containers that can be expanded or contracted on both ends (either its front or its back).
Unlike vectors, deques are not guaranteed to store all its elements in contiguous storage locations: accessing elements in a deque by offsetting a pointer to another element causes undefined behavior.
Example:
Output:
| #define DEFINE_DEQUE | ( | typename, | |
| deque | |||
| ) |
A predefined deque definition with no elements.
| typename | The deque type |
| deque | The deque |
| #define DEFINE_DEQUE_TYPE | ( | typename, | |
| value_type, | |||
| max_size | |||
| ) |
A new deque type definition.
| typename | Name of the new deque type |
| value_type | Type of element. |
| max_size | Maximal size of the deque. It defines the fixed-size of the static defined array. |
| #define DEQUE_AT | ( | deque, | |
| n | |||
| ) |
Returns a pointer to the element at position n in the deque.
| deque | The deque |
| n | Number of elements |
| #define DEQUE_BACK | ( | deque | ) |
Returns a read/write pointer to the data at the last element of the deque.
| deque | The deque |
| #define DEQUE_CLEAR | ( | deque | ) |
Remove all elements from the deque.
| deque | The deque |
| #define DEQUE_EMPTY | ( | deque | ) |
Returns true if the deque is empty.
| deque | The deque |
| #define DEQUE_FILL | ( | deque, | |
| n, | |||
| value | |||
| ) |
Fill container with n elements. Each element is a copy of value.
| deque | The deque |
| n | Number of elements |
| value | Initial value |
| #define DEQUE_FRONT | ( | deque | ) |
Returns a read/write pointer to the data at the first element of the deque.
| deque | The deque |
| #define DEQUE_MAX_SIZE | ( | deque | ) |
Returns the size() of the largest possible deque.
| deque | The deque |
| #define DEQUE_POP_BACK | ( | deque | ) |
Removes the last element.
| deque | The deque This is a typical stack operation. It shrinks the deque by one. |
| #define DEQUE_POP_FRONT | ( | deque | ) |
Removes the first element.
| deque | The deque This is a typical stack operation. It shrinks the deque by one. |
| #define DEQUE_PUSH_BACK | ( | deque, | |
| value | |||
| ) |
Add data to the end of the deque.
| deque | The deque |
| value | Data to be added. |
This is a typical stack operation. The function add an element at the end of the deque. Due to the nature of a deque this operation can be done in constant time.
| #define DEQUE_PUSH_FRONT | ( | deque, | |
| value | |||
| ) |
Add data to the front of the deque.
| deque | The deque |
| value | Data to be added. |
This is a typical stack operation. The function add an element at the front of the deque. Due to the nature of a deque this operation can be done in constant time.
| #define DEQUE_SIZE | ( | deque | ) |
Returns the number of elements in the deque.
| deque | The deque |