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;
79 size_t size() {
return _size; }
87 std::shared_ptr<node> nn = std::make_shared<node>(key);
105 T
top() {
return root->val; }
113 root->next =
nullptr;
139 std::shared_ptr<node> curr_root;
147 explicit Iterator(
const std::shared_ptr<node> &s) noexcept : curr_root(s) {}
156 this->curr_root = current;
167 curr_root = curr_root->prev;
Iterator class.
Definition stack_list.h:137
bool operator!=(const Iterator &it)
operator != for type Iterator
Definition stack_list.h:190
Iterator operator++(int)
operator ++ for type Iterator
Definition stack_list.h:177
Iterator & operator++()
operator ++ for type Iterator
Definition stack_list.h:165
Iterator(const std::shared_ptr< node > &s) noexcept
Construct a new Iterator object.
Definition stack_list.h:147
Iterator & operator=(std::shared_ptr< node > current)
= operator for Iterator type
Definition stack_list.h:155
T operator*()
operator * for type Iterator
Definition stack_list.h:197
stack_list class
Definition stack_list.h:13
T top()
top function
Definition stack_list.h:105
void pop()
pop function removes the top of the stack
Definition stack_list.h:111
size_t size()
size functon
Definition stack_list.h:79
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:86
Iterator end()
pointer to the end of the stack
Definition stack_list.h:131
stack_list & operator=(const stack_list &s)
operator = for stack list class
Definition stack_list.h:60
Iterator begin()
pointer to the top of the stack
Definition stack_list.h:124
stack_list(const stack_list &s)
Copy constructor for stack list class.
Definition stack_list.h:50
void clear()
clear function
Definition stack_list.h:69