8#include "DSCEngine/debug/error.hpp"
12 template<
typename T>
class Stack
20 Item* top_item =
nullptr;
43 void push(
const T& value);
84 top_item = stack.top_item;
85 stack.top_item =
nullptr;
91 top_item = stack.top_item;
92 stack.top_item =
nullptr;
99 return top_item ==
nullptr;
105 Item* item =
new Item();
107 item->next = top_item;
114 nds_assert(top_item!=
nullptr,
"Cannot perform pop on an empty stack");
115 Item* item = top_item;
116 T value = item->value;
117 top_item = top_item->next;
132 while(top_item!=
nullptr)
144 for(T i=a;i<b;i+=step)
150 for(T i=a;i>b;i+=step)
void push(const T &value)
Adds an element at the top of the stack.
Definition: stack.hpp:103
bool is_empty() const
Checks if the stack is empty.
Definition: stack.hpp:97
static Stack< T > from_range(const T &a, const T &b, const T &step)
Creates a stack from all elements ranging between certain values.
Definition: stack.hpp:137
void clear()
Clears the stack.
Definition: stack.hpp:130
T pop()
Removes the element at the top of the stack.
Definition: stack.hpp:112