34 template <
typename T, nat_t CAP = 100>
44 std::swap(array, s.array);
45 std::swap(num_items, s.num_items);
62 : num_items(s.num_items)
78 num_items = s.num_items;
92 return num_items == 0;
97 return num_items == CAP;
118 throw std::overflow_error(
"Stack is full");
120 array[num_items++] = item;
121 return array[num_items - 1];
127 throw std::overflow_error(
"Stack is full");
129 array[num_items++] = std::move(item);
130 return array[num_items - 1];
136 throw std::underflow_error(
"Stack is empty");
138 return array[num_items - 1];
144 throw std::underflow_error(
"Stack is empty");
146 return array[num_items - 1];
152 throw std::underflow_error(
"Stack is empty");
160 throw std::underflow_error(
"Stack is empty");
168 throw std::underflow_error(
"Stack is empty");
170 return std::move(array[--num_items]);
176 throw std::underflow_error(
"n is to large");
182 template <
typename T, nat_t CAP>
185 for (
nat_t i = 0; i < num_items; ++i)
186 array[i] = s.array[i];
189 template <
typename T>
242 return BaseArray::is_empty();
252 return BaseArray::size();
257 BaseArray::append(item);
258 return BaseArray::get_last();
263 BaseArray::append(std::forward<T>(item));
264 return BaseArray::get_last();
270 throw std::underflow_error(
"Stack is empty");
272 return BaseArray::get_last();
278 throw std::underflow_error(
"Stack is empty");
280 return BaseArray::get_last();
286 throw std::underflow_error(
"Stack is empty");
288 return BaseArray::get_first();
294 throw std::underflow_error(
"Stack is empty");
296 return BaseArray::get_first();
302 throw std::underflow_error(
"Stack is empty");
304 return BaseArray::remove_last();
310 template <
typename T>
314 throw std::underflow_error(
"n is to large");
320 template <
typename T>
367 return BaseList::is_empty();
377 return BaseList::size();
382 return BaseList::insert(item);
387 return BaseList::insert(std::forward<T>(item));
393 throw std::underflow_error(
"Stack is empty");
395 return BaseList::get_first();
401 throw std::underflow_error(
"Stack is empty");
403 return BaseList::get_first();
409 throw std::underflow_error(
"Stack is empty");
411 return BaseList::get_last();
417 throw std::underflow_error(
"Stack is empty");
419 return BaseList::get_last();
425 throw std::underflow_error(
"Stack is empty");
427 return BaseList::remove_first();
433 template <
typename T>
437 throw std::underflow_error(
"n is to large");
445 # endif // DSGSTACK_H T & base()
Definition: stack.H:283
const T & base() const
Definition: stack.H:414
T & top()
Definition: stack.H:390
T DataType
Definition: array.H:194
T DataType
Definition: stack.H:51
T & push(const T &item)
Definition: stack.H:380
ListStack(ListStack &&s)
Definition: stack.H:344
T ValueType
Definition: stack.H:52
nat_t SizeType
Definition: stack.H:53
DynStack(DynStack &&s)
Definition: stack.H:219
nat_t size() const
Definition: stack.H:375
T pop()
Definition: stack.H:165
T ValueType
Definition: list.H:211
const T & top() const
Definition: stack.H:398
T KeyType
Definition: stack.H:50
void clear()
Definition: stack.H:370
const T & base() const
Definition: stack.H:157
const T & top() const
Definition: stack.H:141
DynStack()
Definition: stack.H:201
void popn(nat_t)
Definition: stack.H:311
DynStack(nat_t cap)
Definition: stack.H:207
FixedStack(const FixedStack &s)
Definition: stack.H:61
nat_t size() const
Definition: stack.H:105
T KeyType
Definition: list.H:209
T & push(T &&item)
Definition: stack.H:124
T & base()
Definition: stack.H:406
T pop()
Definition: stack.H:299
T ItemType
Definition: array.H:192
T & top()
Definition: stack.H:133
FixedStack & operator=(const FixedStack &s)
Definition: stack.H:73
const T & top() const
Definition: stack.H:275
DynStack(const DynStack &s)
Definition: stack.H:213
void clear()
Definition: stack.H:100
Definition: italgorithms.H:33
bool is_empty() const
Definition: stack.H:240
T ItemType
Definition: stack.H:49
ListStack(const ListStack &s)
Definition: stack.H:338
bool is_empty() const
Definition: stack.H:365
void popn(nat_t n)
Definition: stack.H:173
T DataType
Definition: list.H:210
T & top()
Definition: stack.H:267
nat_t SizeType
Definition: array.H:196
const T & base() const
Definition: stack.H:291
nat_t SizeType
Definition: list.H:212
T pop()
Definition: stack.H:422
nat_t size() const
Definition: stack.H:250
T & push(const T &item)
Definition: stack.H:115
T ValueType
Definition: array.H:195
unsigned long int nat_t
Definition: types.H:50
nat_t get_capacity() const
Definition: stack.H:110
bool is_full() const
Definition: stack.H:95
FixedStack()
Definition: stack.H:55
ListStack()
Definition: stack.H:332
bool is_empty() const
Definition: stack.H:90
void clear()
Definition: stack.H:245
T & base()
Definition: stack.H:149
void popn(nat_t)
Definition: stack.H:434
T & push(T &&item)
Definition: stack.H:385
T ItemType
Definition: list.H:208
T KeyType
Definition: array.H:193
FixedStack(FixedStack &&s)
Definition: stack.H:67
T & push(T &&item)
Definition: stack.H:261
T & push(const T &item)
Definition: stack.H:255