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)];
Doubly-linked list with constant-time indexing.
bool isEmpty() const
Determines if this list is empty.
Value & backValue()
Last element of list.
NodeIterator erase(size_t id)
Erase one element.
IndexedList & pushBack(const Value &value)
Insert at the back of the list.
size_t size() const
Number of elements in list.
const Value & operator[](size_t idx) const
Access an item not at the top of the stack.
const Value & get(size_t idx) const
Access an item not at the top of the stack.
Stack(const boost::iterator_range< Iterator > &range)
Construct a stack from an iterator range.
size_t size() const
Returns the number of items on the stack.
Value & top()
Returns the top item.
Value pop()
Pop existing item from stack.
Stack()
Construct an empty stack.
const Value & top() const
Returns the top item.
Value & operator[](size_t idx)
Access an item not at the top of the stack.
Stack & push(const Value &value)
Push new item onto stack.
Value & get(size_t idx)
Access an item not at the top of the stack.
bool isEmpty() const
Determines if the stack is empty.