STXXL
1.4.1
|
This page introduces into the stxxl::deque container (to learn more about the structure of stxxl::deque, see section Deque).
The acronym Deque stands for "double-ended-queue", that means elements can be accessed, inserted and deleted on both ends of the data structure - in contrast to the stxxl::queue (see STXXL Queue), where that's only possible on one of the two endings.
To create a stxxl::deque object, only the data value type must be specified:
See stxxl::deque for additional template parameter details.
Inserting elements is possible at the start (by calling the push_front() function) as well as the end (by calling the push_back() function) of the deque.
To return a reference to the element at the start of the deque, call front(), to return a reference to the elemtent at the end of the deque, call back() on a deque instance.
Accessing elements at random is supported by the STXXL deque with the []-operator like the following.
The operations described in this sections are not I/O-efficient as they come with time per I/O-access. To achieve I/O-efficient scanning, the STXXL deque provides different iterators. The simplest iterator can be used as follows:
Deleting elements is possible at both endings of the deque by using pop_front() and pop_back():
To determine the size (i.e. the number of elements) of an instance, call size():
To check if the deque is empty, call empty() which returns true if the deque is empty:
(See examples/containers/deque1.cpp for the sourcecode of the following example).
See examples/containers/deque2.cpp for the sourcecode of a more comprehensive example.