This section introduces into the STXXL stack container (to learn more about the structure of stxxl::stack, see section Stack).
STXXL stacks are last in first out (LIFO), i.e. inserting and extracting elements are only allowed from one end of the container and the element on top is the element added most recently.
Before using a STXXL stack, we initially have to define and then to instantiate a stack object. To manage the configuration of the stack type we used the generator template. A minimal configuration is shown below - as one can see the value_type (integer in our case) is the only stricly neccessary parameter. See stxxl::STACK_GENERATOR for additional configuration parameters and information.
Hint: STXXL stack provides specialized implementations for a certain access pattern. If the access pattern is known before, such a customization might gain a significant speedup. The default stack is stxxl::normal_stack which is the best for a random sequence of push'es and pop's. See Stack section for more details.
To insert an element on top of the stack call push():
To access the top element call top():
To remove the top element call pop().
To determine the size (i.e. the number of elements) of stack instance, call size():
To check if the stack is empty, call empty() which returns true in case of emptyness:
(See examples/containers/stack1.cpp for the sourcecode of the following example).
See examples/containers/stack2.cpp for the sourcecode of a more comprehensive example.