A generic internal circular queue. More...
#include <tpie/internal_queue.h>
Inherits tpie::linear_memory_base< internal_queue< T > >.
Public Member Functions | |
internal_queue (size_t size=0) | |
Construct a queue. More... | |
void | resize (size_t size=0) |
Resize the queue; all data is lost. More... | |
const T & | front () const |
Return the item that has been in the queue for the longest time. More... | |
const T & | back () const |
Return the last item pushed to the queue. More... | |
void | push (T val) |
Add an element to the front of the queue. More... | |
void | pop () |
Remove an element from the back of the queue. More... | |
bool | empty () const |
Check if the queue is empty. More... | |
bool | full () const |
Check if the queue is empty. More... | |
size_t | size () const |
Return the number of elements in the queue. More... | |
void | clear () |
Clear the queue of all elements. More... | |
Static Public Member Functions | |
static double | memory_coefficient () |
Return the memory coefficient of the structure. More... | |
static double | memory_overhead () |
Return the memory overhead of the structure. More... | |
static memory_size_type | memory_usage (memory_size_type size) |
Return the number of bytes required to create a data structure supporting a given number of elements. More... | |
static memory_size_type | memory_fits (memory_size_type memory) |
Return the maximum number of elements that can be contained in in the structure when it is allowed to fill a given number of bytes. More... | |
A generic internal circular queue.
The queue supports a fixed number of unpopped elements between calls to clear. The number of elements is given as an argument to the constructor or to resize.
T | The type of items stored in the queue |
Definition at line 42 of file internal_queue.h.
|
inline |
Construct a queue.
size | The number of pushes supported between calls to clear and resize. |
Definition at line 64 of file internal_queue.h.
|
inline |
|
inline |
Clear the queue of all elements.
After this call, the queue again supports the number of pushes passed to the constructor or resize.
Definition at line 118 of file internal_queue.h.
|
inline |
Check if the queue is empty.
Definition at line 99 of file internal_queue.h.
Referenced by tpie::internal_queue< item_type >::front().
|
inline |
Return the item that has been in the queue for the longest time.
Definition at line 76 of file internal_queue.h.
Referenced by tpie::pipelining::parallel_bits::producer< T1, T2 >::end().
|
inline |
Check if the queue is empty.
Definition at line 105 of file internal_queue.h.
|
inlinestatic |
Return the memory coefficient of the structure.
Allocating a structure with n elements will use at most bytes. This does not include memory overhead incurred if the structure is allocated using new.
Definition at line 50 of file internal_queue.h.
|
inlinestaticinherited |
Return the maximum number of elements that can be contained in in the structure when it is allowed to fill a given number of bytes.
memory | The number of bytes the structure is allowed to occupy |
|
inlinestatic |
Return the memory overhead of the structure.
Definition at line 56 of file internal_queue.h.
|
inlinestaticinherited |
Return the number of bytes required to create a data structure supporting a given number of elements.
size | The number of elements to support |
|
inline |
Remove an element from the back of the queue.
Definition at line 93 of file internal_queue.h.
Referenced by tpie::pipelining::parallel_bits::producer< T1, T2 >::end().
|
inline |
Add an element to the front of the queue.
val | The element to add. |
Definition at line 88 of file internal_queue.h.
|
inline |
Resize the queue; all data is lost.
size | The number of elements to contain. |
Definition at line 71 of file internal_queue.h.
|
inline |
Return the number of elements in the queue.
Definition at line 111 of file internal_queue.h.
Referenced by tpie::internal_queue< item_type >::internal_queue(), and tpie::internal_queue< item_type >::resize().