Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::ArrayStack< T > Class Template Reference

Stack implemented with simple dynamic array and with bounds verification. More...

#include <tpl_arrayStack.H>

Inheritance diagram for Aleph::ArrayStack< T >:
[legend]
Collaboration diagram for Aleph::ArrayStack< T >:
[legend]

Classes

class  Iterator
 Iterator on the items of a stack. More...
 

Public Types

using Item_Type = T
 
using Const_Iterator = Aleph::Const_Iterator< Iterator >
 Read-only iterator: the iterator of a constant container.
 
- Public Types inherited from StlAlephIterator< ArrayStack< T > >
using iterator = StlIterator< ArrayStack< T > >
 
using const_iterator = StlConstIterator< ArrayStack< T > >
 

Public Member Functions

 ArrayStack (size_t dim=4)
 The type of element.
 
 ArrayStack (const ArrayStack &s)
 Copy constructor.
 
 ArrayStack (ArrayStack &&s) noexcept
 Move constructor.
 
template<template< typename > class List>
 ArrayStack (const List< T > &l)
 
template<class It >
requires (not std::is_arithmetic_v<It> and requires (It it) { *it; ++it; it != it; })
 ArrayStack (It b, It e)
 
 ArrayStack (std::initializer_list< T > l)
 
ArrayStack & operator= (const ArrayStack &s)
 Assign by copy s to this
 
void swap (ArrayStack &s) noexcept
 Swap this with s
 
ArrayStack & operator= (ArrayStack &&s) noexcept
 Assign by moving s to this
 
T & push (const T &data)
 Push into stack a copy of data
 
T & push (T &&data)
 Push into stack data
 
T & append (const T &data)
 See push(const T & data).
 
T & append (T &&data)
 See push(T && data).
 
T & insert (const T &data)
 See push(const T & data).
 
T & insert (T &&data)
 See push(T && data).
 
T & pushn (const size_t &n=1)
 Push n cells into the stack.
 
T pop ()
 Extract the last more recently inserted element.
 
T pop_ne () noexcept
 
T popn (size_t n)
 Extract in constant time the n more recently inserted elements of stack.
 
T & top ()
 Return a modifiable reference to youngest element of stack (called the top)
 
const T & top () const
 
T & base ()
 Return a modifiable reference to the oldest element (the base).
 
const T & base () const
 Return a constant reference to the oldest element (the base).
 
T & top (const size_t i)
 Return a modifiable reference to the element located at i positions from top.
 
const T & top (const size_t i) const
 
T & get_last ()
 
const T & get_last () const
 
void empty () noexcept
 Empty the stack.
 
void clear () noexcept
 Empties the container.
 
bool is_empty () const noexcept
 Return true if stack is empty.
 
size_t size () const noexcept
 Return the number of elements stored in the stack.
 
size_t capacity () const noexcept
 Return the internal capacity.
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, T &>
bool traverse (Operation &operation) noexcept(noexcept(array.traverse(operation)))
 Traverse all the items of stack from the youngest to oldest and conditionally performs an operation.
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, const T &>
bool traverse (Operation &operation) const noexcept(noexcept(array.traverse(operation)))
 See traverse(Operation & operation).
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, const T &>
bool traverse (Operation &&operation=Operation()) const noexcept(noexcept(array.traverse(operation)))
 See traverse(Operation & operation).
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, T &>
bool traverse (Operation &&operation=Operation()) noexcept(noexcept(array.traverse(operation)))
 See traverse(Operation & operation).
 
- Public Member Functions inherited from LocateFunctions< ArrayStack< T >, T >
auto get_it ()
 Return a properly initialized iterator positioned at the first item on the container.
 
auto get_it () const
 Read-only iterator positioned at the first item.
 
auto get_it (const size_t pos)
 Return a properly initialized iterator positioned at the pos item on the container.
 
auto get_it (const size_t pos) const
 Read-only iterator positioned at the pos item.
 
auto get_itor ()
 Alias of get_it().
 
auto get_itor () const
 See get_itor().
 
T & nth_ne (const size_t n) noexcept(Aleph::dry_detail::mutable_traversal_is_noexcept< C, T >)
 Return the n‑th element without bounds checking.
 
const T & nth_ne (const size_t n) const noexcept(Aleph::dry_detail::const_traversal_is_noexcept< ArrayStack< T >, T >)
 Constant overload of nth_ne(size_t).
 
T & nth (const size_t n)
 Return the n-th item of the container.
 
const T & nth (const size_t n) const
 Const overload of nth(size_t).
 
and Aleph::dry_detail::MutablyTraversable< typename Aleph::concepts_detail::defer< ArrayStack< T >, Operation >::type, T > T * find_ptr (Operation &operation) noexcept(mutable_search_is_noexcept< Operation >())
 Find a pointer to an item in the container according to a searching criterion.
 
const T * find_ptr (Operation &operation) const noexcept(const_search_is_noexcept< Operation >())
 Const overload of find_ptr(Operation&).
 
const T * find_ptr (Operation &&operation) const noexcept(const_search_is_noexcept< Operation >())
 Overload of find_ptr() const that accepts rvalues.
 
and Aleph::dry_detail::MutablyTraversable< typename Aleph::concepts_detail::defer< ArrayStack< T >, Operation >::type, T > T * find_ptr (Operation &&operation) noexcept(mutable_search_is_noexcept< Operation >())
 Overload of find_ptr() that accepts rvalues.
 
size_t find_index (Operation &operation) const noexcept(const_search_is_noexcept< Operation >())
 Find the position of an item in the container according to a searching criterion.
 
size_t find_index (Operation &&operation) const noexcept(const_search_is_noexcept< Operation >())
 Overload of find_index() that accepts rvalues.
 
and std::default_initializable< T > and std::copy_constructible< T > std::tuple< bool, T > find_item (Operation &operation) const noexcept(find_item_is_noexcept< Operation >())
 Safe sequential searching of an item matching a criterion.
 
and std::default_initializable< T > and std::copy_constructible< T > std::tuple< bool, T > find_item (Operation &&operation) const noexcept(find_item_is_noexcept< Operation >())
 Overload of find_item() that accepts rvalues.
 
and std::copy_constructible< T > std::optional< T > find_opt (Operation &operation) const
 Copy of the first item satisfying a criterion, if any.
 
and std::copy_constructible< T > std::optional< T > find_opt (Operation &&operation) const
 Overload of find_opt() that accepts rvalues.
 
bool contains_if (Operation &&operation) const noexcept(const_search_is_noexcept< Operation >())
 Test if an item satisfying a criterion is present in the container.
 
bool contains (const T &item) const
 Test if an item is present in the container using equality.
 
- Public Member Functions inherited from FunctionalMethods< ArrayStack< T >, T >
void emplace (Args &&... args)
 Appends a new element into the container by constructing it from the given args.
 
void emplace_end (Args &&... args)
 See emplace(Args && ... args).
 
void emplace_ins (Args &&... args)
 
size_t ninsert (Args &&... args)
 Insert n variadic items.
 
size_t nappend (Args &&... args)
 Append n variadic items.
 
void for_each (Operation &operation) const
 Traverse all the container and performs an operation on each element.
 
void for_each (Operation &&operation) const
 Overload of for_each() that accepts rvalues.
 
void each (Operation &operation) const
 Alias of for_each().
 
void each (Operation &&operation) const
 Alias of for_each() that accepts rvalues.
 
void each (const size_t pos, const size_t slice, Operation &operation) const
 Traverse the container starting at pos taking one item every slice, performing an operation on each visited element.
 
void each (const size_t pos, const size_t slice, Operation &&operation) const
 See each(size_t pos, size_t slice, Operation & operation) const.
 
and Aleph::dry_detail::MutablyTraversable< typename Aleph::concepts_detail::defer< ArrayStack< T >, Operation >::type, T > void each (const size_t pos, const size_t slice, Operation &operation)
 Traverse the container starting at pos taking one item every slice, performing an operation that may modify each visited item.
 
and Aleph::dry_detail::MutablyTraversable< typename Aleph::concepts_detail::defer< ArrayStack< T >, Operation >::type, T > void each (const size_t pos, const size_t slice, Operation &&operation)
 See each(size_t pos, size_t slice, Operation & operation).
 
and Aleph::dry_detail::MutablyTraversable< typename Aleph::concepts_detail::defer< ArrayStack< T >, Operation >::type, T > void mutable_for_each (Operation &operation)
 Apply a mutable operation to each element of the container.
 
and Aleph::dry_detail::MutablyTraversable< typename Aleph::concepts_detail::defer< ArrayStack< T >, Operation >::type, T > void mutable_for_each (Operation &&operation)
 See mutable_for_each(Operation & operation).
 
bool all (Operation &operation) const
 Check if all the elements of the container satisfy a condition.
 
bool all (Operation &&operation) const
 Overload of all() that accepts rvalues.
 
bool exists (Operation &op) const
 Test for existence in the container of an element satisfying a criterion.
 
bool exists (Operation &&op) const
 Overload of exists() that accepts rvalues.
 
bool none (Operation &op) const
 Test that no element satisfies a criterion.
 
bool none (Operation &&op) const
 Overload of none() that accepts rvalues.
 
size_t count_if (Operation &op) const
 Count the elements that satisfy a criterion.
 
size_t count_if (Operation &&op) const
 Overload of count_if() that accepts rvalues.
 
Aleph::DynList< Aleph::dry_detail::map_result_t< R, Operation &, T > > maps (Operation &op) const
 
Aleph::DynList< Aleph::dry_detail::map_result_t< R, Operation &, T > > maps (Operation &&op) const
 
Aleph::DynList< Aleph::dry_detail::map_result_t< R, Operation &, T > > maps_if (Prop prop, Operation &op) const
 
Aleph::DynList< Aleph::dry_detail::map_result_t< R, Operation &, T > > maps_if (Prop prop, Operation &&op) const
 
Aleph::DynList< Aleph::dry_detail::map_result_t< R, Operation &, T > > map (Operation &op) const
 
Aleph::DynList< Aleph::dry_detail::map_result_t< R, Operation &, T > > map (Operation &&op) const
 
Aleph::DynList< Aleph::dry_detail::map_result_t< R, Operation &, T > > map_if (Prop prop, Operation &op) const
 
Aleph::DynList< Aleph::dry_detail::map_result_t< R, Operation &, T > > map_if (Prop prop, Operation &&op) const
 
auto flat_map (Operation &op) const
 Map each element to a container and concatenate the results.
 
auto flat_map (Operation &&op) const
 Overload of flat_map() that accepts rvalues.
 
Aleph::DynList< T > to_dynlist () const
 Convert container to DynList.
 
std::vector< T > to_vector () const
 Convert container to std::vector.
 
Acc foldl (const Acc &init, Op &op) const
 Fold the elements of the container to a specific result.
 
Acc foldl (const Acc &init, Op &&op) const
 Overload of foldl() that accepts rvalues.
 
Acc fold_left (const Acc &init, Op &op) const
 Alias for foldl().
 
Acc fold_left (const Acc &init, Op &&op) const
 Overload of fold_left() that accepts rvalues.
 
T fold (const T &init, Operation &operation) const
 Simplified version of foldl() where the folded type is the same type of elements stored in the container.
 
T fold (const T &init, Operation &&operation) const
 Overload of fold() that accepts rvalues.
 
Acc foldr (const Acc &init, Op &op) const
 Fold the elements from the last to the first.
 
Acc foldr (const Acc &init, Op &&op) const
 Overload of foldr() that accepts rvalues.
 
and std::copy_constructible< U > std::optional< T > reduce (Op &op) const
 Fold the elements with no initial value.
 
and std::copy_constructible< U > std::optional< T > reduce (Op &&op) const
 Overload of reduce() that accepts rvalues.
 
Aleph::DynList< T > filter (Operation &operation) const
 Filter the elements of a container according to a matching criterion.
 
Aleph::DynList< T > filter (Operation &&operation) const
 Overload of filter() that accepts rvalues.
 
Aleph::DynList< const T * > ptr_filter (Operation &operation) const
 Filter the elements of a container according to a matching criterion and return a pointer to the matched items in the container.
 
Aleph::DynList< const T * > ptr_filter (Operation &&operation) const
 Overload of ptr_filter() that accepts rvalues.
 
Aleph::DynList< std::tuple< T, size_t > > pfilter (Operation &operation) const
 Filter the elements of a container according to a matching criterion and determine its positions respect to the traversal of container.
 
Aleph::DynList< std::tuple< T, size_t > > pfilter (Operation &&operation) const
 Overload of pfilter() that accepts rvalues.
 
std::pair< Aleph::DynList< T >, Aleph::DynList< T > > partition (Operation &op) const
 Exclusive partition of container according to a filter criterion.
 
std::pair< Aleph::DynList< T >, Aleph::DynList< T > > partition (Operation &&op) const
 Overload of partition() that accepts rvalues.
 
std::pair< Aleph::DynList< T >, Aleph::DynList< T > > partition (size_t n) const
 Exclusive partition of container in the nth item.
 
std::pair< Aleph::DynList< T >, Aleph::DynList< T > > split_half () const
 Split the container into two halves by alternating elements.
 
std::tuple< Aleph::DynList< T >, Aleph::DynList< T > > tpartition (Operation &op) const
 Exclusive partition of container according to a filter criterion.
 
std::tuple< Aleph::DynList< T >, Aleph::DynList< T > > tpartition (Operation &&op) const
 Overload of tpartition() that accepts rvalues.
 
size_t length () const noexcept(Aleph::dry_detail::const_traversal_is_noexcept< ArrayStack< T >, T >)
 Count the number of elements of a container.
 
Aleph::DynList< T > rev () const
 Return a list with the elements of container in reverse order respect to its traversal order.
 
Aleph::DynList< T > take (const size_t n) const
 Return a list with the first n elements seen in the container during its traversal.
 
Aleph::DynList< T > take (size_t i, const size_t j, const size_t step=1) const
 Return a list with the elements at positions i, i + step, i + 2 step, ... that are not greater than j, respect to the traversal order.
 
Aleph::DynList< T > drop (const size_t n) const
 Drop the first n elements seen in the container during its traversal.
 
Aleph::DynList< T > take_while (Operation &op) const
 The longest prefix of elements that satisfy a criterion.
 
Aleph::DynList< T > take_while (Operation &&op) const
 Overload of take_while() that accepts rvalues.
 
Aleph::DynList< T > drop_while (Operation &op) const
 The elements after the longest prefix that satisfies a criterion.
 
Aleph::DynList< T > drop_while (Operation &&op) const
 Overload of drop_while() that accepts rvalues.
 
void mutable_drop (const size_t n)
 Drop the first n elements seen from container.
 
- Public Member Functions inherited from GenericItems< Container, T >
Aleph::DynList< T > items () const
 Return a list of all the elements of a container sorted by traversal order.
 
Aleph::DynList< T > keys () const
 See items().
 
- Public Member Functions inherited from EqualSequenceMethod< ArrayStack< T > >
bool equal_to (const ArrayStack< T > &r) const
 Equality test between this and r.
 
- Public Member Functions inherited from StlAlephIterator< ArrayStack< T > >
iterator begin () noexcept
 Return an STL-compatible iterator to the first element.
 
const_iterator begin () const noexcept
 Return a const iterator to the first element.
 
iterator end () noexcept
 Return an STL-compatible end iterator.
 
const_iterator end () const noexcept
 Return a const end iterator.
 
const_iterator cbegin () const noexcept
 Return a const iterator to the first element.
 
const_iterator cend () const noexcept
 Return a const end iterator.
 

Private Attributes

MemArray< T > array
 

Additional Inherited Members

- Static Public Member Functions inherited from FunctionalMethods< ArrayStack< T >, T >
static ArrayStack< T > build (Items &&... items)
 Build a container that holds the given items.
 
static D build_as (Items &&... items)
 Build a D, a class derived from the container, holding the given items.
 
- Public Attributes inherited from FunctionalMethods< ArrayStack< T >, T >
 and
 Insert a new element into the container by constructing it from the given args.
 
and Aleph::InvocableWith< Operation &, const T & > and
 Conditional mapping of the elements of the container.
 

Detailed Description

template<typename T>
class Aleph::ArrayStack< T >

Stack implemented with simple dynamic array and with bounds verification.

ArrayStack<T> instruments a stack of elements of generic type T. The stack is store into an internal contiguous array which grows and ungrows dynamically according to the number of elements.

ArrayStack<T> is a good trade-off between performance and memory consumption. In general is faster than a stack implemented with linked list, but since the internal array growths in two powers, the waste of memory could reach twice the number of elements.

You could use FixedStack, which other than the internal array does not dynamically grow, it does not still perform bound_min_clock checks.

See also
FixedStack DynListStack

Definition at line 80 of file tpl_arrayStack.H.

Member Typedef Documentation

◆ Const_Iterator

Read-only iterator: the iterator of a constant container.

Definition at line 381 of file tpl_arrayStack.H.

◆ Item_Type

template<typename T >
using Aleph::ArrayStack< T >::Item_Type = T

Definition at line 89 of file tpl_arrayStack.H.

Constructor & Destructor Documentation

◆ ArrayStack() [1/6]

template<typename T >
Aleph::ArrayStack< T >::ArrayStack ( size_t  dim = 4)
inline

The type of element.

Initializes a stack with a capacity of dim

Definition at line 92 of file tpl_arrayStack.H.

◆ ArrayStack() [2/6]

template<typename T >
Aleph::ArrayStack< T >::ArrayStack ( const ArrayStack< T > &  s)
inline

Copy constructor.

Definition at line 97 of file tpl_arrayStack.H.

◆ ArrayStack() [3/6]

template<typename T >
Aleph::ArrayStack< T >::ArrayStack ( ArrayStack< T > &&  s)
inlinenoexcept

Move constructor.

Definition at line 102 of file tpl_arrayStack.H.

◆ ArrayStack() [4/6]

template<typename T >
template<template< typename > class List>
Aleph::ArrayStack< T >::ArrayStack ( const List< T > &  l)
inline

Definition at line 106 of file tpl_arrayStack.H.

◆ ArrayStack() [5/6]

template<typename T >
template<class It >
requires (not std::is_arithmetic_v<It> and requires (It it) { *it; ++it; it != it; })
Aleph::ArrayStack< T >::ArrayStack ( It  b,
It  e 
)
inline

Definition at line 106 of file tpl_arrayStack.H.

◆ ArrayStack() [6/6]

template<typename T >
Aleph::ArrayStack< T >::ArrayStack ( std::initializer_list< T >  l)
inline

Definition at line 106 of file tpl_arrayStack.H.

Member Function Documentation

◆ append() [1/2]

template<typename T >
T & Aleph::ArrayStack< T >::append ( const T &  data)
inline

See push(const T & data).

Definition at line 155 of file tpl_arrayStack.H.

References Aleph::ArrayStack< T >::push().

◆ append() [2/2]

template<typename T >
T & Aleph::ArrayStack< T >::append ( T &&  data)
inline

See push(T && data).

Definition at line 161 of file tpl_arrayStack.H.

References Aleph::ArrayStack< T >::push().

◆ base() [1/2]

template<typename T >
T & Aleph::ArrayStack< T >::base ( )
inline

Return a modifiable reference to the oldest element (the base).

Returns
Reference to the bottom of the stack.
Exceptions
std::underflow_errorif the stack is empty.

Definition at line 239 of file tpl_arrayStack.H.

References Aleph::ArrayStack< T >::array.

Referenced by TEST().

◆ base() [2/2]

template<typename T >
const T & Aleph::ArrayStack< T >::base ( ) const
inline

Return a constant reference to the oldest element (the base).

Returns
Constant reference to the bottom of the stack.
Exceptions
std::underflow_errorif the stack is empty.

Definition at line 248 of file tpl_arrayStack.H.

References Aleph::ArrayStack< T >::array.

◆ capacity()

template<typename T >
size_t Aleph::ArrayStack< T >::capacity ( ) const
inlinenoexcept

Return the internal capacity.

Definition at line 315 of file tpl_arrayStack.H.

References Aleph::ArrayStack< T >::array.

Referenced by TEST(), and TEST().

◆ clear()

template<typename T >
void Aleph::ArrayStack< T >::clear ( )
inlinenoexcept

Empties the container.

Exceptions
none
See also
empty()

Definition at line 297 of file tpl_arrayStack.H.

References Aleph::ArrayStack< T >::empty().

◆ empty()

template<typename T >
void Aleph::ArrayStack< T >::empty ( )
inlinenoexcept

Empty the stack.

Definition at line 287 of file tpl_arrayStack.H.

References Aleph::ArrayStack< T >::array.

Referenced by Aleph::ArrayStack< T >::clear().

◆ get_last() [1/2]

template<typename T >
T & Aleph::ArrayStack< T >::get_last ( )
inline

Definition at line 276 of file tpl_arrayStack.H.

References Aleph::ArrayStack< T >::top().

◆ get_last() [2/2]

template<typename T >
const T & Aleph::ArrayStack< T >::get_last ( ) const
inline

Definition at line 281 of file tpl_arrayStack.H.

References Aleph::ArrayStack< T >::top().

◆ insert() [1/2]

template<typename T >
T & Aleph::ArrayStack< T >::insert ( const T &  data)
inline

See push(const T & data).

Definition at line 167 of file tpl_arrayStack.H.

References Aleph::ArrayStack< T >::push().

◆ insert() [2/2]

template<typename T >
T & Aleph::ArrayStack< T >::insert ( T &&  data)
inline

See push(T && data).

Definition at line 173 of file tpl_arrayStack.H.

References Aleph::ArrayStack< T >::push().

◆ is_empty()

template<typename T >
bool Aleph::ArrayStack< T >::is_empty ( ) const
inlinenoexcept

◆ operator=() [1/2]

template<typename T >
ArrayStack & Aleph::ArrayStack< T >::operator= ( ArrayStack< T > &&  s)
inlinenoexcept

Assign by moving s to this

Definition at line 126 of file tpl_arrayStack.H.

References Aleph::ArrayStack< T >::array, and Aleph::ArrayStack< T >::swap().

◆ operator=() [2/2]

template<typename T >
ArrayStack & Aleph::ArrayStack< T >::operator= ( const ArrayStack< T > &  s)
inline

Assign by copy s to this

Definition at line 109 of file tpl_arrayStack.H.

References Aleph::ArrayStack< T >::array.

◆ pop()

template<typename T >
T Aleph::ArrayStack< T >::pop ( )
inline

Extract the last more recently inserted element.

Returns
a copy of extracted element
Exceptions
underflow_errorif stack is empty

Definition at line 200 of file tpl_arrayStack.H.

References Aleph::ArrayStack< T >::array.

Referenced by fib_st(), fib_stack(), Aleph::Gen_Link_Cut_Tree< T, Monoid, LazyTag >::inorder_traverse(), Aleph::lazy_post_order(), Aleph::Gen_Link_Cut_Tree< T, Monoid, LazyTag >::splay(), and TEST().

◆ pop_ne()

template<typename T >
T Aleph::ArrayStack< T >::pop_ne ( )
inlinenoexcept

Definition at line 205 of file tpl_arrayStack.H.

References Aleph::ArrayStack< T >::array.

◆ popn()

template<typename T >
T Aleph::ArrayStack< T >::popn ( size_t  n)
inline

Extract in constant time the n more recently inserted elements of stack.

Parameters
[in]nnumber of elements to pop
Returns
a copy of last extracted element
Exceptions
underflow_errorif n is greater than stack size

Definition at line 217 of file tpl_arrayStack.H.

References ah_invalid_argument_if, and Aleph::ArrayStack< T >::array.

◆ push() [1/2]

template<typename T >
T & Aleph::ArrayStack< T >::push ( const T &  data)
inline

Push into stack a copy of data

Parameters
[in]datato be pushed by copy
Returns
a modifiable reference to the copy of inserted data
Exceptions
bad_allocif there is no enough memory

Definition at line 138 of file tpl_arrayStack.H.

References Aleph::ArrayStack< T >::array.

Referenced by SimpleStack::SimpleStack(), Aleph::ArrayStack< T >::append(), Aleph::ArrayStack< T >::append(), fib_st(), Aleph::Gen_Link_Cut_Tree< T, Monoid, LazyTag >::inorder_traverse(), Aleph::ArrayStack< T >::insert(), Aleph::ArrayStack< T >::insert(), Aleph::lazy_post_order(), Aleph::Gen_Link_Cut_Tree< T, Monoid, LazyTag >::splay(), TEST(), TEST(), TEST(), TEST(), and TEST().

◆ push() [2/2]

template<typename T >
T & Aleph::ArrayStack< T >::push ( T &&  data)
inline

Push into stack data

Parameters
[in]datato be pushed by moving
Returns
a modifiable reference to the moved inserted data
Exceptions
bad_allocif there is no enough memory

Definition at line 149 of file tpl_arrayStack.H.

References Aleph::ArrayStack< T >::array.

◆ pushn()

template<typename T >
T & Aleph::ArrayStack< T >::pushn ( const size_t &  n = 1)
inline

Push n cells into the stack.

pushn(n) is functionally equivalent to perform n pushes of T() in constant time. The idea is to reserve enough space for later use.

Parameters
[in]nnumber of cells to reserve
Returns
a modifiable reference to the stack's top
Exceptions
bad_allocif there is no enough memory

Definition at line 188 of file tpl_arrayStack.H.

References ah_invalid_argument_if, and Aleph::ArrayStack< T >::array.

Referenced by fib_stack().

◆ size()

template<typename T >
size_t Aleph::ArrayStack< T >::size ( ) const
inlinenoexcept

Return the number of elements stored in the stack.

Definition at line 309 of file tpl_arrayStack.H.

References Aleph::ArrayStack< T >::array.

Referenced by fib_st(), fib_stack(), TEST(), TEST(), TEST(), TEST_F(), and TEST_F().

◆ swap()

template<typename T >
void Aleph::ArrayStack< T >::swap ( ArrayStack< T > &  s)
inlinenoexcept

Swap this with s

Definition at line 120 of file tpl_arrayStack.H.

References Aleph::ArrayStack< T >::array.

Referenced by Aleph::ArrayStack< T >::operator=().

◆ top() [1/4]

template<typename T >
T & Aleph::ArrayStack< T >::top ( )
inline

Return a modifiable reference to youngest element of stack (called the top)

Definition at line 225 of file tpl_arrayStack.H.

References Aleph::ArrayStack< T >::array.

Referenced by fib_stack(), Aleph::ArrayStack< T >::get_last(), Aleph::ArrayStack< T >::get_last(), Aleph::lazy_post_order(), TEST(), TEST(), TEST(), TEST(), TEST_F(), and TEST_F().

◆ top() [2/4]

template<typename T >
const T & Aleph::ArrayStack< T >::top ( ) const
inline

Definition at line 230 of file tpl_arrayStack.H.

References Aleph::ArrayStack< T >::array.

◆ top() [3/4]

template<typename T >
T & Aleph::ArrayStack< T >::top ( const size_t  i)
inline

Return a modifiable reference to the element located at i positions from top.

Parameters
[in]inúmero of positions
Returns
a modifiable reference to the element at i positions after top
Exceptions
out_of_rangeif i is greater than the number of elements of stack

Definition at line 262 of file tpl_arrayStack.H.

References ah_out_of_range_error_if, and Aleph::ArrayStack< T >::array.

◆ top() [4/4]

template<typename T >
const T & Aleph::ArrayStack< T >::top ( const size_t  i) const
inline

Definition at line 269 of file tpl_arrayStack.H.

References ah_out_of_range_error_if, and Aleph::ArrayStack< T >::array.

◆ traverse() [1/4]

template<typename T >
template<class Operation >
requires Aleph::PredicateWith<Operation &, const T &>
bool Aleph::ArrayStack< T >::traverse ( Operation &&  operation = Operation()) const
inlinenoexcept

See traverse(Operation & operation).

Definition at line 345 of file tpl_arrayStack.H.

References Aleph::ArrayStack< T >::array.

◆ traverse() [2/4]

template<typename T >
template<class Operation >
requires Aleph::PredicateWith<Operation &, T &>
bool Aleph::ArrayStack< T >::traverse ( Operation &&  operation = Operation())
inlinenoexcept

See traverse(Operation & operation).

Definition at line 354 of file tpl_arrayStack.H.

References Aleph::ArrayStack< T >::array.

◆ traverse() [3/4]

template<typename T >
template<class Operation >
requires Aleph::PredicateWith<Operation &, const T &>
bool Aleph::ArrayStack< T >::traverse ( Operation &  operation) const
inlinenoexcept

See traverse(Operation & operation).

Definition at line 337 of file tpl_arrayStack.H.

References Aleph::ArrayStack< T >::array.

◆ traverse() [4/4]

template<typename T >
template<class Operation >
requires Aleph::PredicateWith<Operation &, T &>
bool Aleph::ArrayStack< T >::traverse ( Operation &  operation)
inlinenoexcept

Traverse all the items of stack from the youngest to oldest and conditionally performs an operation.

Parameters
[in]operationto perform on the current element. If it returns true, the traversal continues to the next item; otherwise the traversal stops

Definition at line 329 of file tpl_arrayStack.H.

References Aleph::ArrayStack< T >::array.

Referenced by TEST().

Member Data Documentation

◆ array


The documentation for this class was generated from the following files: