19 #ifndef __TPIE_INTERNAL_QUEUE_H__
20 #define __TPIE_INTERNAL_QUEUE_H__
44 size_t m_first, m_last;
81 const T &
back()
const {
return m_elements[(m_last-1) % m_elements.
size()];}
88 inline void push(T val){m_elements[m_last++ % m_elements.
size()] = val;}
93 inline void pop(){++m_first;}
99 inline bool empty()
const {
return m_first == m_last;}
105 inline bool full()
const {
return m_last - m_first == m_elements.
size();}
111 inline size_t size()
const {
return m_last - m_first;}
118 inline void clear(){m_first = m_last =0;}
122 #endif //__TPIE_INTERNAL_QUEUE_H__
internal_queue(size_t size=0)
Construct a queue.
Defines the tp_assert macro.
bool full() const
Check if the queue is empty.
Base class of data structures with linear memory usage.
const T & back() const
Return the last item pushed to the queue.
const T & front() const
Return the item that has been in the queue for the longest time.
A generic internal circular queue.
size_t size() const
Return the number of elements in the queue.
static double memory_overhead()
Return the memory overhead of the structure.
Generic internal array with known memory requirements.
void clear()
Clear the queue of all elements.
void push(T val)
Add an element to the front of the queue.
void pop()
Remove an element from the back of the queue.
Miscellaneous utility functions.
static double memory_coefficient()
Return the memory coefficient of the structure.
void resize(size_t size, const T &elm)
Change the size of the array.
bool empty() const
Check if the queue is empty.
static double memory_overhead()
Return the memory overhead of the structure.
size_type size() const
Return the size of the array.
#define tp_assert(condition, message)
static double memory_coefficient()
Return the memory coefficient of the structure.
void resize(size_t size=0)
Resize the queue; all data is lost.