23 std::shared_ptr<node> next;
24 std::shared_ptr<node> prev;
25 node(T key) : val(key), next(
nullptr), prev(
nullptr) {}
28 std::shared_ptr<node> root;
37 inline explicit stack_list(std::vector<T> v = {})
noexcept : root(nullptr) {
75 inline size_t size() {
return _size; }
83 std::shared_ptr<node> nn = std::make_shared<node>(key);
101 inline T
top() {
return root->val; }
109 root->next =
nullptr;
135 std::shared_ptr<node> curr_root;
143 explicit Iterator(
const std::shared_ptr<node>& s) noexcept : curr_root(s) {}
152 this->curr_root = current;
163 curr_root = curr_root->prev;
Iterator class.
Definition stack_list.h:133
bool operator!=(const Iterator &it)
operator != for type Iterator
Definition stack_list.h:186
Iterator operator++(int)
operator ++ for type Iterator
Definition stack_list.h:173
Iterator & operator++()
operator ++ for type Iterator
Definition stack_list.h:161
Iterator(const std::shared_ptr< node > &s) noexcept
Construct a new Iterator object.
Definition stack_list.h:143
Iterator & operator=(std::shared_ptr< node > current)
= operator for Iterator type
Definition stack_list.h:151
T operator*()
operator * for type Iterator
Definition stack_list.h:193
T top()
top function
Definition stack_list.h:101
void pop()
pop function removes the top of the stack
Definition stack_list.h:107
size_t size()
size functon
Definition stack_list.h:75
stack_list(std::vector< T > v={}) noexcept
Construct a new stack list object.
Definition stack_list.h:37
void push(T key)
push function
Definition stack_list.h:82
Iterator end()
pointer to the end of the stack
Definition stack_list.h:127
stack_list & operator=(const stack_list &s)
operator = for stack list class
Definition stack_list.h:56
Iterator begin()
pointer to the top of the stack
Definition stack_list.h:120
stack_list(const stack_list &s)
Copy constructor for stack list class.
Definition stack_list.h:49
void clear()
clear function
Definition stack_list.h:65