A simple LIFO stack backed by std::vector.
More...
#include <containers.hpp>
|
| void | clear () |
| | Remove all elements.
|
| |
| bool | empty () const |
| | Check if the stack is empty.
|
| |
| T | pop () |
| | Remove and return the top element.
|
| |
| void | push (const T &value) |
| | Push a value onto the top of the stack.
|
| |
| std::size_t | size () const |
| | Get the number of elements.
|
| |
| const T & | top () const |
| | Peek at the top element without removing it.
|
| |
template<typename T>
class containers::Stack< T >
A simple LIFO stack backed by std::vector.
- Template Parameters
-
- Note
- This is intentionally simple — it demonstrates how doxyYoda renders template class documentation, not a production container.
- See also
- RingBuffer for a fixed-capacity alternative.
-
yoda::Vec2 for another template class example.
Definition at line 85 of file containers.hpp.
◆ clear()
◆ empty()
Check if the stack is empty.
Definition at line 120 of file containers.hpp.
120{ return data_.empty(); }
◆ pop()
Remove and return the top element.
- Returns
- The top element.
- Exceptions
-
- Precondition
!empty()
Definition at line 102 of file containers.hpp.
102 {
104 T val = data_.back();
105 data_.pop_back();
107 }
A simple LIFO stack backed by std::vector.
◆ push()
Push a value onto the top of the stack.
- Parameters
-
- Postcondition
size() is incremented by 1.
Definition at line 92 of file containers.hpp.
92 {
93 data_.push_back(
value);
94 }
◆ size()
Get the number of elements.
Definition at line 123 of file containers.hpp.
123{ return data_.size(); }
◆ top()
Peek at the top element without removing it.
- Returns
- A const reference to the top element.
- Exceptions
-
Definition at line 114 of file containers.hpp.
114 {
116 return data_.back();
117 }
The documentation for this class was generated from the following file: