Shared Queue
Defined in header <haz/SharedQueue.hpp>
template<
class T,
std::size_t N
> class SharedQueue;
SharedQueue is an fixed size queue with additional functions to controle multiple access at the same time. The elements are stored contiguously in a buffer of size N, but are not in order. The iterators will iterate through the collection in order of insertion though.
Complexity: - Insertion at the beginning and removal at the end of elements: constant O(1) - Random Access: constant O(1)
Template parameters
T: The type of the elements N: The maximum number of element in the buffer
It is recommended to use a power of 2 for the size S so the index is computed faster.
Members functions
Element access
| at | Access specified element with bounds checking |
| back | Access the last element |
| front | Access the first element |
| operator [] | Access specified element without bounds checking |
Iterators
| begin, cbegin | Returns an iterator to the beginning |
| end, cend | Returns an iterator to the end |
| rbegin, crbegin | Returns a reverse iterator to the beginning |
| end, cend | Returns a reverse iterator to the end |
Capacity
| capacity | Returns the maximum number of elements |
| empty | Checks whether the container is empty |
| max_size | Returns the maximum number of elements |
| size | Returns the number of elements |
Modifiers
| assign | Replaces the content |
| clear | Clear the content |
| emplace_back | Construct an element in-place at the end |
| pop_front | Pop the first element |
| push_back | Insert an element to the end |
| swap | Swaps the contents |
Non-member function
| operator ==, !=, <=, >=, <, > | Lexicograpically compares the values |
| std::swap | specialize the std::swap algorithm |