STXXL
1.4.0
|
This page introduces into the stxxl::queue Container (to learn more about the structure of stxxl::stack, see section Queue).
Before using a STXXL queue, we initially have to define and then to instantiate a queue object. The implementation holds the head and the tail blocks in the main memory. Prefetch and write block pools might be used to overlap I/O and computation during queue operations. A minimal configuration is shown below - the value_type (integer in our example case) is the only stricly neccessary parameter. The default configuration initializes a write_pool and a prefetch_pool of size 1.
The STXXL queue implementation provides three different types of constructors to customize your individual caching. See stxxl::queue more details. Additional optional template parameters are block_size, allocation_strategy, size_type, see stxxl::queue for further details.
To insert a new value at the beginning of the queue, call push(). Accessing elements are possible on both endings of the queue, back() returns the value at the beginning, front() returns the value at the end. Deleting a value by pop() erases the first inserted element.
To determine the number of elements a queue currently stores, call size():
To check if the queue is empty, call empty() which returns true in that case:
(See examples/containers/queue1.cpp for the sourcecode of the following example).
See examples/containers/queue2.cpp for the sourcecode of a more comprehensive example.