11 #include <Sawyer/Assert.h>
12 #include <Sawyer/IndexedList.h>
32 template<
class Iterator>
33 Stack(
const boost::iterator_range<Iterator> &range) {
34 for (Iterator iter = range.begin(); iter != range.end(); ++iter)
61 const Value&
top()
const {
73 Value&
get(
size_t idx) {
74 ASSERT_require(idx <
size());
75 return items_[items_.
size() - (idx+1)];
77 const Value&
get(
size_t idx)
const {
78 ASSERT_require(idx <
size());
79 return items_[items_.
size() - (idx+1)];
Value pop()
Pop existing item from stack.
IndexedList & pushBack(const Value &value)
Insert at the back of the list.
Stack()
Construct an empty stack.
Stack & push(const Value &value)
Push new item onto stack.
NodeIterator erase(size_t id)
Erase one element.
bool isEmpty() const
Determines if the stack is empty.
Value & operator[](size_t idx)
Access an item not at the top of the stack.
bool isEmpty() const
Determines if this list is empty.
Value & backValue()
Last element of list.
const Value & get(size_t idx) const
Access an item not at the top of the stack.
Value & top()
Returns the top item.
size_t size() const
Number of elements in list.
Stack(const boost::iterator_range< Iterator > &range)
Construct a stack from an iterator range.
Value & get(size_t idx)
Access an item not at the top of the stack.
size_t size() const
Returns the number of items on the stack.
const Value & operator[](size_t idx) const
Access an item not at the top of the stack.
Name space for the entire library.
const Value & top() const
Returns the top item.