20 #ifndef __TPIE_QUEUE_H__
21 #define __TPIE_QUEUE_H__
47 queue(stream_size_type elements=std::numeric_limits<stream_size_type>::max(),
48 double block_factor=1.0): m_size(0), m_file(block_factor) {
50 m_back.attach(m_file);
51 m_front.attach(m_file);
66 queue(
const std::string& basename,
double block_factor=1.0);
71 ~queue() {m_file.write_user_data(m_back.offset());}
77 inline bool empty() {
return m_size == 0;}
78 TPIE_DEPRECATED(
bool is_empty());
84 inline stream_size_type
size() {
return m_size;}
90 inline void push(
const T & t) {
94 TPIE_DEPRECATED(
ami::err enqueue(
const T &t));
101 const T & el = m_front.read();
105 TPIE_DEPRECATED(
ami::err dequeue(
const T **t));
112 const T & el = m_front.read();
113 m_front.seek(-1, file_base::stream::current);
116 TPIE_DEPRECATED(
ami::err peek(
const T **t));
136 TPIE_DEPRECATED(
void persist(persistence p));
139 stream_size_type m_size;
147 void queue<T>::persist(persistence p) {
153 m_temp(basename), m_size(0), m_file(blockFactor), m_back(m_file), m_front(m_file) {
156 if (m_file.size() != 0) {
158 m_file.read_user_data(t);
161 m_back.seek(0, file_base::stream::end);
162 m_size = m_back.offset() - m_front.offset();
174 ami::err queue<T>::enqueue(
const T &t) {
182 ami::err queue<T>::dequeue(
const T **t) {
190 ami::err queue<T>::peek(
const T **t) {
196 TPIE_DEPRECATED_CLASS_A(
197 template <typename T>
201 queue(
const std::string& basename): tpie::queue<T>(basename) {}
206 #endif // __TPIE_QUEUE_H__
Central stream abstraction.
PERSIST_DELETE
Delete the stream from the disk when it is destructed.
void unused(const T &x)
Declare that a variable is unused on purpose.
Central file abstraction.
Macros for deprecating classes, methods and typedefs.
This file contains a few deprecated definitions for legacy code.
Streams that support substreams.
~queue()
Destructor, closes the underlying stream.
void set_persistent(bool p)
Set persistence.
queue(stream_size_type elements=std::numeric_limits< stream_size_type >::max(), double block_factor=1.0)
Constructor for Temporary Queue.
stream_size_type size()
Returns the number of items currently on the queue.
const T & pop()
Dequeues an item.
bool empty()
Check if the queue is empty.
static memory_size_type memory_usage(double blockFactor=1.0)
Compute the memory used by the queue.
Class representing the existence of a temporary file.
void resize(stream_size_type)
Does nothing.
Persistence tags for deprecated TPIE AMI streams.
void push(const T &t)
Enqueue an item.
Basic Implementation of I/O Efficient FIFO queue.
err
Legacy TPIE error codes.
const T & front()
Returns at the frontmost item in the queue.
Open a file for reading or writing.