Nvwa
1.1
|
Class to represent a fixed-capacity queue. More...
#include <fc_queue.h>
Public Member Functions | |
fc_queue (size_type max_size, const allocator_type &alloc=allocator_type()) | |
Constructor that creates the queue with a maximum size (capacity). More... | |
fc_queue (const fc_queue &rhs) | |
Copy-constructor that copies all elements from another queue. More... | |
~fc_queue () | |
Destructor. More... | |
fc_queue & | operator= (const fc_queue &rhs) |
Assignment operator that copies all elements from another queue. More... | |
bool | empty () const noexcept |
Checks whether the queue is empty (containing no elements). More... | |
bool | full () const noexcept |
Checks whether the queue is full (containing the maximum allowed elements). More... | |
size_type | capacity () const noexcept |
Gets the maximum number of allowed elements in the queue. More... | |
size_type | size () const noexcept |
Gets the number of existing elements in the queue. More... | |
reference | front () |
Gets the first element in the queue. More... | |
const_reference | front () const |
Gets the first element in the queue. More... | |
reference | back () |
Gets the last element in the queue. More... | |
const_reference | back () const |
Gets the last element in the queue. More... | |
void | push (const value_type &value) |
Inserts a new element at the end of the queue. More... | |
void | pop () |
Discards the first element in the queue. More... | |
bool | contains (const value_type &value) const |
Checks whether the queue contains a specific element. More... | |
void | swap (fc_queue &rhs) |
Exchanges the elements of two queues. More... | |
allocator_type | get_allocator () const |
Gets the allocator of the queue. More... | |
Class to represent a fixed-capacity queue.
This class has an interface close to std::queue
, but it allows very efficient and lockless one-producer, one-consumer access, as long as the producer does not try to queue an element when the queue is already full.
_Tp | the type of elements in the queue |
_Alloc | allocator to use for memory management |
CopyConstructible
and Destructible
, and _Alloc shall meet the allocator requirements (Table 28 in the C++11 spec).
|
inlineexplicit |
Constructor that creates the queue with a maximum size (capacity).
max_size | the maximum size allowed |
alloc | the allocator to use |
empty()
! full()
capacity() == max_size
size() == 0
get_allocator() == alloc
nvwa::fc_queue< _Tp, _Alloc >::fc_queue | ( | const fc_queue< _Tp, _Alloc > & | rhs | ) |
Copy-constructor that copies all elements from another queue.
rhs | the queue to copy |
|
inline |
Destructor.
It erases all elements and frees memory.
|
inline |
Gets the last element in the queue.
|
inline |
Gets the last element in the queue.
|
inlinenoexcept |
Gets the maximum number of allowed elements in the queue.
|
inline |
Checks whether the queue contains a specific element.
value | the value to be compared |
value_type
shall be EqualityComparable
. true
if found; false
otherwise
|
inlinenoexcept |
Checks whether the queue is empty (containing no elements).
true
if it is empty; false
otherwise
|
inline |
Gets the first element in the queue.
|
inline |
Gets the first element in the queue.
|
inlinenoexcept |
Checks whether the queue is full (containing the maximum allowed elements).
true
if it is full; false
otherwise
|
inline |
Gets the allocator of the queue.
|
inline |
Assignment operator that copies all elements from another queue.
rhs | the queue to copy |
|
inline |
|
inline |
Inserts a new element at the end of the queue.
The first element will be discarded if the queue is full.
value | the value to be inserted |
size() <= capacity() && back() == value
, unless an exception is thrown, in which case this queue is unchanged (strong exception safety is guaranteed).
|
inlinenoexcept |
Gets the number of existing elements in the queue.
|
inline |
Exchanges the elements of two queues.
rhs | the queue to exchange with |
*this
will be swapped with rhs. If swapping the allocators throws with strong exception safety guarantee, this function will also provide such guarantee.