3 * \file limited_stack.h
4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS
12 #ifndef LIMITED_STACK_H
13 #define LIMITED_STACK_H
18 * limited_stack - a stack of limited size
20 * Like a normal stack, but elements falling out
21 * of the bottom are destructed.
26 typedef std::list<T> container_type;
27 typedef typename container_type::value_type value_type;
28 typedef typename container_type::size_type size_type;
30 /// limit is the maximum size of the stack
31 limited_stack(size_type limit = 100) {
35 /// return the top element
40 /// pop and throw away the top element
45 /// return true if the stack is empty
47 return c_.size() == 0;
50 /// clear all elements, deleting them
57 /// push an item on to the stack, deleting the
58 /// bottom item on overflow.
59 void push(value_type const & v) {
61 if (c_.size() > limit_) {
69 /// the maximum number elements stored
73 // make pointer type an error.
75 class limited_stack<T*>;
77 #endif // LIMITED_STACK_H