46#ifndef TPL_ARRAYSTACK_H
47#define TPL_ARRAYSTACK_H
99 :
array(std::move(s.array)) { }
135 return array.put(data);
146 return array.put(std::forward<T>(data));
189 return array.get_ne(1);
214 return array.first();
228 const size_t sz =
array.size();
230 return array.access(sz - i - 1);
254 template <
class Operation>
261 template <
class Operation>
268 template <
class Operation>
275 template <
class Operation>
313 template <
typename T>
347 for (
int i = 0; i <
head; ++i)
356 std::swap(
array, s.array);
357 std::swap(
head, s.head);
358 std::swap(
dim, s.dim);
374 T * ptr =
new T [s.
dim];
378 for (
size_t i = 0; i < s.
head; ++i)
482 T &
top(
size_t i)
const noexcept
504 template <
class Operation>
507 for (
int i = 0; i <
head; i++)
515 template <
class Operation>
522 template <
class Operation>
529 template <
class Operation>
Variadic constructor macros for containers.
Container traversal and functional operation mixins.
Exception handling system with formatted messages for Aleph-w.
#define ah_out_of_range_error_if(C)
Throws std::out_of_range if condition holds.
#define Special_Ctors(Set_Type, Type)
Generates special constructors for containers.
Core header for the Aleph-w library.
Iterator on the items of a stack.
typename MemArray< T >::Iterator Base
Iterator(const ArrayStack< T > &s)
Initialize an iterator on stack s
Stack implemented with simple dynamic array and with bounds verification.
void swap(ArrayStack &s) noexcept
Swap this with s
bool traverse(Operation &&operation=Operation())
T & insert(const T &data)
T & top() const
Return a modifiable reference to youngest element of stack (called the top)
void empty() noexcept
Empty the stack.
ArrayStack(const ArrayStack &s)
Copy constructor.
ArrayStack(size_t dim=4)
The type of element.
bool is_empty() const noexcept
Return true if stack is empty.
ArrayStack & operator=(const ArrayStack &s)
Assign by copy s to this
bool traverse(Operation &operation)
Traverse all the items of stack from the youngest to oldest and conditionally performs an operation.
size_t size() const noexcept
Return the number of elements stored in the stack.
T & pushn(const size_t &n=1)
Push n cells into the stack.
T & append(const T &data)
T & top(size_t i) const
Return a modifiable reference to the element located at i positions from top.
bool traverse(Operation &operation) const
T & base() noexcept
Return a modifiable reference to first element of array.
T popn(size_t n)
Extract in constant time the n more recently inserted elements of stack.
T pop()
Extract the last more recently inserted element.
bool traverse(Operation &&operation=Operation()) const
T & push(const T &data)
Push into stack a copy of data
ArrayStack(ArrayStack &&s) noexcept
Move constructor.
size_t capacity() const noexcept
Return the internal capacity.
T & push(T &&data)
Push into stack data
Iterator wrapper for C++ raw arrays.
Iterator on the items of a stack.
Iterator(const FixedStack< T > &s)
T & append(const T &data) noexcept
T & push(const T &data) noexcept
Push a copy of data
bool traverse(Operation &&operation=Operation()) const
FixedStack & operator=(const FixedStack &s)
Assign by copy s to this
size_t size() const noexcept
Return the number of elements stored in the stack.
T & pushn(const size_t &n=1) noexcept
Push in contant time nspaces into stack.
T & top(size_t i) const noexcept
Return a modifiable referecce to item located i positions after top.
T & insert(const T &data) noexcept
T popn(const int &n) noexcept
Perform in constant time n pops.
bool traverse(Operation &&operation=Operation())
T & base() const noexcept
Return the internal array base.
T & get_last() const noexcept
T & insert(T &&data) noexcept
bool is_empty() const noexcept
Return true if stack is empty.
bool traverse(Operation &operation)
Traverse all the items of stack from the youngest to oldest and conditionally performs an operation.
T & append(T &&data) noexcept
FixedStack(const FixedStack &s)
Copy constructor.
T & push(T &&data) noexcept
Push and move data
T & top() const noexcept
Return a modifiable referemce to stack's top.
T pop() noexcept
Pop by moving the top of stack.
FixedStack(FixedStack &&s) noexcept
Move constructor.
void empty() noexcept
Empty the stack.
bool traverse(Operation &operation) const
FixedStack(size_t d=1024)
The type of element.
void swap(FixedStack &s) noexcept
Swap in constant time s with this
Simple, scalable and fast dynamic array.
Equality test for containers.
Common methods to the Aleph-w ( ) containers.
Aleph::DynList< __T > maps(Operation &op) const
Map the elements of the container.
Common sequential searching methods on containers.
Mixin that adds STL begin()/end() and cbegin()/cend() to Aleph containers.
__gmp_expr< typename __gmp_resolve_expr< T, V >::value_type, __gmp_binary_expr< __gmp_expr< T, U >, __gmp_expr< V, W >, __gmp_dim_function > > dim(const __gmp_expr< T, U > &expr1, const __gmp_expr< V, W > &expr2)
Singly linked list implementations with head-tail access.
Main namespace for Aleph-w library functions.
std::decay_t< typename HeadC::Item_Type > T
Simple iterator on elements of array.
Generic list of items stored in a container.
Dynamic doubly linked list implementation.
Simple, scalable, contiguous dynamic array.