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

Dynamic stack of elements of generic type T based on a singly linked list. More...

#include <tpl_dynListStack.H>

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

Classes

struct  Iterator
 Iterator for traversing elements of the stack. More...
 

Public Types

using Set_Type = DynListStack
 The container type (self-reference for generic programming).
 
using Item_Type = T
 The type of elements stored in the stack.
 
using Key_Type = T
 Alias for Item_Type.
 
using Const_Iterator = Aleph::Const_Iterator< Iterator >
 Read-only iterator: the iterator of a constant container.
 
- Public Types inherited from StlAlephIterator< DynListStack< T > >
using iterator = StlIterator< DynListStack< T > >
 
using const_iterator = StlConstIterator< DynListStack< T > >
 

Public Member Functions

void swap (DynListStack &other) noexcept
 Swap the contents of this stack with another.
 
 DynListStack () noexcept
 Construct an empty stack.
 
 DynListStack (const DynListStack &other)
 Copy constructor.
 
 DynListStack (DynListStack &&other) noexcept
 Move constructor.
 
template<template< typename > class List>
 DynListStack (const List< T > &l)
 Enable special constructors from ah-args-ctor.H (initializer_list, etc.)
 
template<class It >
requires (not std::is_arithmetic_v<It> and requires (It it) { *it; ++it; it != it; })
 DynListStack (It b, It e)
 
 DynListStack (std::initializer_list< T > l)
 
DynListStack & operator= (const DynListStack &rhs)
 Copy assignment operator.
 
DynListStack & operator= (DynListStack &&rhs) noexcept
 Move assignment operator.
 
size_t size () const noexcept
 Return the number of elements in the stack.
 
bool is_empty () const noexcept
 Check if the stack is empty.
 
T & push (const T &data)
 Push an item by copy onto the top of the stack.
 
T & push (T &&data)
 Push an item by move onto the top of the stack.
 
template<typename... Args>
T & emplace (Args &&... args)
 Construct an item in place at the top of the stack.
 
T & append (const T &data)
 Alias for push() - required by Special_Ctors macro.
 
T & append (T &&data)
 See append(const T & data).
 
T & put (const T &data)
 Alias for push() - for compatibility with queue-like interfaces.
 
T & put (T &&data)
 See put(const T & data).
 
T & insert (const T &data)
 Alias for push() - for STL-like insert semantics.
 
T & insert (T &&data)
 See insert(const T & data).
 
T pop ()
 Remove and return the top item of the stack.
 
T get ()
 Alias for pop() - removes and returns the top item.
 
T & top ()
 Return a modifiable reference to the top item of the stack.
 
const T & top () const
 Return a const reference to the top item of the stack.
 
T & peek ()
 Alias for top() - returns reference to top item.
 
const T & peek () const
 Alias for top() const - returns const reference to top item.
 
void empty () noexcept
 Remove all elements from the stack.
 
void clear () noexcept
 Empties the container.
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, T &>
bool traverse (Operation &operation) noexcept(noexcept(s.traverse(operation)))
 Traverse all elements from top to bottom.
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, const T &>
bool traverse (Operation &operation) const noexcept(noexcept(s.traverse(operation)))
 See traverse(Operation & operation).
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, const T &>
bool traverse (Operation &&operation=Operation()) const noexcept(noexcept(s.traverse(operation)))
 See traverse(Operation & operation).
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, T &>
bool traverse (Operation &&operation=Operation()) noexcept(noexcept(s.traverse(operation)))
 See traverse(Operation & operation).
 
T * search (const T &key) noexcept(noexcept(static_cast< bool >(std::declval< const T & >()==std::declval< const T & >())))
 Search for an item in the stack using equality comparison.
 
const T * search (const T &key) const noexcept(noexcept(static_cast< bool >(std::declval< const T & >()==std::declval< const T & >())))
 See search(const T & key).
 
bool contains (const T &key) const noexcept(noexcept(static_cast< bool >(std::declval< const T & >()==std::declval< const T & >())))
 Check if the stack contains a specific value.
 
bool has (const T &key) const noexcept(noexcept(static_cast< bool >(std::declval< const T & >()==std::declval< const T & >())))
 Alias for contains().
 
- Public Member Functions inherited from LocateFunctions< DynListStack< 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< DynListStack< 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< DynListStack< 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< DynListStack< 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< DynListStack< 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< DynListStack< 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< DynListStack< 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< DynListStack< 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< DynListStack< 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< DynListStack< 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< DynListStack< T > >
bool equal_to (const DynListStack< T > &r) const
 Equality test between this and r.
 
- Public Member Functions inherited from StlAlephIterator< DynListStack< 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

DynList< T > s
 

Additional Inherited Members

- Static Public Member Functions inherited from FunctionalMethods< DynListStack< T >, T >
static DynListStack< 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< DynListStack< 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::DynListStack< T >

Dynamic stack of elements of generic type T based on a singly linked list.

DynListStack<T> models a dynamic LIFO (Last-In-First-Out) stack with O(1) time complexity for push, pop, and top operations. The stack grows and shrinks dynamically as elements are added or removed.

Features

  • O(1) operations: push, pop, top, size, is_empty
  • Unbounded capacity: limited only by available memory
  • Move semantics: efficient transfer of ownership
  • Functional interface: supports traverse, maps, filter, foldl, etc.
  • STL-compatible iteration: supports range-based for loops

Example Usage

stack.push(10);
stack.push(20);
stack.push(30);
while (!stack.is_empty())
std::cout << stack.pop() << " "; // Output: 30 20 10
// Using initializer list
DynListStack<std::string> names = {"Alice", "Bob", "Charlie"};
// Functional operations
auto doubled = stack.maps([](int x) { return x * 2; });
Dynamic stack of elements of generic type T based on a singly linked list.
bool is_empty() const noexcept
Check if the stack is empty.
T pop()
Remove and return the top item of the stack.
T & push(const T &data)
Push an item by copy onto the top of the stack.
Aleph::DynList< Aleph::dry_detail::map_result_t< R, Operation &, T > > maps(Operation &op) const
Definition ah-dry.H:1829

Thread Safety

This class is not thread-safe. External synchronization is required for concurrent access from multiple threads.

Template Parameters
TType of elements stored in the stack. Must be copy-constructible or move-constructible.
See also
DynListQueue For a FIFO queue implementation
ArrayStack For a fixed-capacity array-based stack
FixedStack For a compile-time fixed-size stack
Author
Leandro Rabindranath León

Definition at line 105 of file tpl_dynListStack.H.

Member Typedef Documentation

◆ Const_Iterator

template<typename T >
using Aleph::DynListStack< T >::Const_Iterator = Aleph::Const_Iterator<Iterator>

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

Definition at line 550 of file tpl_dynListStack.H.

◆ Item_Type

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

The type of elements stored in the stack.

Definition at line 120 of file tpl_dynListStack.H.

◆ Key_Type

template<typename T >
using Aleph::DynListStack< T >::Key_Type = T

Alias for Item_Type.

Definition at line 123 of file tpl_dynListStack.H.

◆ Set_Type

template<typename T >
using Aleph::DynListStack< T >::Set_Type = DynListStack

The container type (self-reference for generic programming).

Definition at line 117 of file tpl_dynListStack.H.

Constructor & Destructor Documentation

◆ DynListStack() [1/6]

template<typename T >
Aleph::DynListStack< T >::DynListStack ( )
inlinenoexcept

Construct an empty stack.

Creates a stack with no elements. The stack is ready to accept elements via push() or emplace().

Time complexity: O(1)

Definition at line 147 of file tpl_dynListStack.H.

◆ DynListStack() [2/6]

template<typename T >
Aleph::DynListStack< T >::DynListStack ( const DynListStack< T > &  other)
inline

Copy constructor.

Constructs a new stack as a copy of other. All elements are copied in LIFO order.

Time complexity: O(n) where n is the size of other.

Parameters
[in]otherThe stack to copy from.
Exceptions
std::bad_allocIf memory allocation fails.
Anyexception thrown by T's copy constructor.

Definition at line 160 of file tpl_dynListStack.H.

◆ DynListStack() [3/6]

template<typename T >
Aleph::DynListStack< T >::DynListStack ( DynListStack< T > &&  other)
inlinenoexcept

Move constructor.

Constructs a new stack by transferring ownership of resources from other. After this operation, other is left in a valid but unspecified state (typically empty).

Time complexity: O(1)

Parameters
[in,out]otherThe stack to move from.

Definition at line 176 of file tpl_dynListStack.H.

References Aleph::DynListStack< T >::swap().

◆ DynListStack() [4/6]

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

Enable special constructors from ah-args-ctor.H (initializer_list, etc.)

Definition at line 182 of file tpl_dynListStack.H.

◆ DynListStack() [5/6]

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

Definition at line 182 of file tpl_dynListStack.H.

◆ DynListStack() [6/6]

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

Definition at line 182 of file tpl_dynListStack.H.

Member Function Documentation

◆ append() [1/2]

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

Alias for push() - required by Special_Ctors macro.

Parameters
[in]dataThe item to append.
Returns
Reference to the newly added item.

Definition at line 298 of file tpl_dynListStack.H.

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

Referenced by TEST().

◆ append() [2/2]

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

See append(const T & data).

Definition at line 301 of file tpl_dynListStack.H.

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

◆ clear()

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

Empties the container.

Exceptions
none
See also
empty()

Definition at line 405 of file tpl_dynListStack.H.

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

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

◆ contains()

template<typename T >
bool Aleph::DynListStack< T >::contains ( const T &  key) const
inlinenoexcept

Check if the stack contains a specific value.

Time complexity: O(n)

Parameters
[in]keyThe value to search for.
Returns
true if key is found in the stack, false otherwise.

Definition at line 487 of file tpl_dynListStack.H.

References Aleph::DynListStack< T >::search().

Referenced by Aleph::DynListStack< T >::has(), and TEST().

◆ emplace()

template<typename T >
template<typename... Args>
T & Aleph::DynListStack< T >::emplace ( Args &&...  args)
inline

Construct an item in place at the top of the stack.

Constructs an element directly at the top of the stack using the provided arguments. This avoids the overhead of creating a temporary object and then copying or moving it.

Time complexity: O(1)

Template Parameters
ArgsTypes of the constructor arguments.
Parameters
[in]argsArguments to forward to the constructor of T.
Returns
A modifiable reference to the newly constructed item.
Exceptions
std::bad_allocIf memory allocation fails.
Anyexception thrown by T's constructor.
Note
Internally, this constructs the object and then moves it. For true in-place construction, the underlying container would need to support allocator-aware construction.

Definition at line 289 of file tpl_dynListStack.H.

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

Referenced by TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().

◆ empty()

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

Remove all elements from the stack.

After this call, size() returns 0 and is_empty() returns true.

Time complexity: O(n) where n is the number of elements.

Definition at line 395 of file tpl_dynListStack.H.

References Aleph::DynList< T >::empty(), and Aleph::DynListStack< T >::s.

Referenced by Aleph::DynListStack< T >::clear(), Aleph::Tarjan_Connected_Components< GT, Itor, SA >::init_tarjan(), TEST(), TEST(), TEST(), and TEST().

◆ get()

template<typename T >
T Aleph::DynListStack< T >::get ( )
inline

Alias for pop() - removes and returns the top item.

Returns
A copy of the removed item.
Exceptions
std::underflow_errorIf the stack is empty.

Definition at line 345 of file tpl_dynListStack.H.

References Aleph::DynListStack< T >::pop().

Referenced by Aleph::blossom_weighted_detail::mwmatching::impl::MatchingContext< WeightType >::augment_blossom(), Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::check_blossom(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST_F().

◆ has()

template<typename T >
bool Aleph::DynListStack< T >::has ( const T &  key) const
inlinenoexcept

Alias for contains().

Definition at line 494 of file tpl_dynListStack.H.

References Aleph::DynListStack< T >::contains().

◆ insert() [1/2]

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

Alias for push() - for STL-like insert semantics.

Parameters
[in]dataThe item to insert.
Returns
Reference to the newly added item.

Definition at line 316 of file tpl_dynListStack.H.

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

Referenced by TEST(), TEST(), and TEST().

◆ insert() [2/2]

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

See insert(const T & data).

Definition at line 319 of file tpl_dynListStack.H.

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

◆ is_empty()

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

Check if the stack is empty.

Time complexity: O(1)

Returns
true if the stack contains no elements, false otherwise.

Definition at line 237 of file tpl_dynListStack.H.

References Aleph::HTList::is_empty(), and Aleph::DynListStack< T >::s.

Referenced by Aleph::Gen_Centroid_Decomposition< GT, SA >::append_centroid_annotations(), Aleph::blossom_weighted_detail::mwmatching::impl::MatchingContext< WeightType >::augment_blossom(), brute_path_distinct(), brute_subtree_distinct(), Aleph::Gen_Mo_On_Trees< GT, Policy >::build(), Aleph::Gen_Mo_On_Tree_Node< T, Policy >::build(), Aleph::Gen_Centroid_Decomposition< GT, SA >::build_centroid_tree(), Aleph::Gen_Heavy_Light_Decomposition< GT, SA >::build_decomposition(), Aleph::lca_detail::Rooted_Tree_Data< GT, SA >::build_dfs_data(), Aleph::tree_dp_detail::Tree_Topology< GT, SA >::build_order(), Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::check_blossom(), Aleph::Gen_Centroid_Decomposition< GT, SA >::collect_component_nodes(), Aleph::hld_detail::HLD_Tree_Data< GT, SA >::compute_hld_positions(), Aleph::hld_detail::HLD_Tree_Data< GT, SA >::compute_sizes_and_parents(), Aleph::Tarjan_Connected_Components< GT, Itor, SA >::connected_components(), demo_comparison(), demo_stack(), Aleph::Lengauer_Tarjan_Dominators< GT, SA >::dfs(), Aleph::Gen_Heavy_Light_Decomposition< GT, SA >::for_each_path_segment_id(), Aleph::Tarjan_Connected_Components< GT, Itor, SA >::is_connected(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), Aleph::Tarjan_Connected_Components< GT, Itor, SA >::test_connectivity(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and Aleph::tree_decomposition_detail::Rooted_Tree_Topology< GT, SA >::validate_connected_acyclic().

◆ operator=() [1/2]

template<typename T >
DynListStack & Aleph::DynListStack< T >::operator= ( const DynListStack< T > &  rhs)
inline

Copy assignment operator.

Replaces the contents of this stack with a copy of rhs.

Time complexity: O(n + m) where n is the current size and m is the size of rhs.

Parameters
[in]rhsThe stack to copy from.
Returns
Reference to this stack.
Exceptions
std::bad_allocIf memory allocation fails.
Anyexception thrown by T's copy constructor.

Definition at line 196 of file tpl_dynListStack.H.

References Aleph::DynListStack< T >::s.

◆ operator=() [2/2]

template<typename T >
DynListStack & Aleph::DynListStack< T >::operator= ( DynListStack< T > &&  rhs)
inlinenoexcept

Move assignment operator.

Replaces the contents of this stack by transferring ownership from rhs. After this operation, rhs is left in a valid but unspecified state.

Time complexity: O(1) (plus destruction of current elements).

Parameters
[in,out]rhsThe stack to move from.
Returns
Reference to this stack.

Definition at line 217 of file tpl_dynListStack.H.

References Aleph::DynListStack< T >::s, and Aleph::DynList< T >::swap().

◆ peek() [1/2]

template<typename T >
T & Aleph::DynListStack< T >::peek ( )
inline

Alias for top() - returns reference to top item.

Returns
Reference to the top item.
Exceptions
std::underflow_errorIf the stack is empty.

Definition at line 381 of file tpl_dynListStack.H.

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

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

◆ peek() [2/2]

template<typename T >
const T & Aleph::DynListStack< T >::peek ( ) const
inline

Alias for top() const - returns const reference to top item.

Returns
Const reference to the top item.
Exceptions
std::underflow_errorIf the stack is empty.

Definition at line 387 of file tpl_dynListStack.H.

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

◆ pop()

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

Remove and return the top item of the stack.

Removes the most recently pushed item from the stack and returns it.

Time complexity: O(1)

The item moves out before it leaves the stack, so that if its move throws the stack keeps it, and its size.

Returns
The removed item.
Exceptions
std::underflow_errorIf the stack is empty.
Warning
Calling pop() on an empty stack throws an exception. Use is_empty() to check before calling.

Definition at line 336 of file tpl_dynListStack.H.

References Aleph::DynList< T >::remove_first(), and Aleph::DynListStack< T >::s.

Referenced by Aleph::Gen_Centroid_Decomposition< GT, SA >::append_centroid_annotations(), brute_path_distinct(), brute_subtree_distinct(), Aleph::Gen_Mo_On_Trees< GT, Policy >::build(), Aleph::Gen_Mo_On_Tree_Node< T, Policy >::build(), Aleph::Gen_Centroid_Decomposition< GT, SA >::build_centroid_tree(), Aleph::Gen_Heavy_Light_Decomposition< GT, SA >::build_decomposition(), Aleph::lca_detail::Rooted_Tree_Data< GT, SA >::build_dfs_data(), Aleph::tree_dp_detail::Tree_Topology< GT, SA >::build_order(), Aleph::Gen_Centroid_Decomposition< GT, SA >::collect_component_nodes(), Aleph::hld_detail::HLD_Tree_Data< GT, SA >::compute_hld_positions(), Aleph::hld_detail::HLD_Tree_Data< GT, SA >::compute_sizes_and_parents(), demo_comparison(), demo_stack(), Aleph::Lengauer_Tarjan_Dominators< GT, SA >::dfs(), Aleph::Gen_Heavy_Light_Decomposition< GT, SA >::for_each_path_segment_id(), Aleph::DynListStack< T >::get(), main(), Aleph::Tarjan_Connected_Components< GT, Itor, SA >::pop_from_stack(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and Aleph::tree_decomposition_detail::Rooted_Tree_Topology< GT, SA >::validate_connected_acyclic().

◆ push() [1/2]

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

Push an item by copy onto the top of the stack.

Adds a copy of data to the top of the stack.

Time complexity: O(1)

Parameters
[in]dataThe item to be copied and pushed.
Returns
A modifiable reference to the newly pushed item.
Exceptions
std::bad_allocIf memory allocation fails.
Anyexception thrown by T's copy constructor.

Definition at line 250 of file tpl_dynListStack.H.

References Aleph::DynList< T >::insert(), and Aleph::DynListStack< T >::s.

Referenced by StringStack::StringStack(), Aleph::DynListStack< T >::append(), Aleph::DynListStack< T >::append(), Aleph::Gen_Centroid_Decomposition< GT, SA >::append_centroid_annotations(), brute_path_distinct(), brute_subtree_distinct(), Aleph::Gen_Mo_On_Trees< GT, Policy >::build(), Aleph::Gen_Mo_On_Tree_Node< T, Policy >::build(), Aleph::Gen_Centroid_Decomposition< GT, SA >::build_centroid_tree(), Aleph::Gen_Heavy_Light_Decomposition< GT, SA >::build_decomposition(), Aleph::lca_detail::Rooted_Tree_Data< GT, SA >::build_dfs_data(), Aleph::tree_dp_detail::Tree_Topology< GT, SA >::build_order(), Aleph::Gen_Centroid_Decomposition< GT, SA >::collect_component_nodes(), Aleph::hld_detail::HLD_Tree_Data< GT, SA >::compute_hld_positions(), Aleph::hld_detail::HLD_Tree_Data< GT, SA >::compute_sizes_and_parents(), demo_comparison(), demo_stack(), Aleph::Lengauer_Tarjan_Dominators< GT, SA >::dfs(), Aleph::DynListStack< T >::emplace(), Aleph::Gen_Heavy_Light_Decomposition< GT, SA >::for_each_path_segment_id(), Aleph::Tarjan_Connected_Components< GT, Itor, SA >::init_node_and_push_in_stack(), Aleph::DynListStack< T >::insert(), Aleph::DynListStack< T >::insert(), main(), Aleph::DynListStack< T >::put(), Aleph::DynListStack< T >::put(), DynListStackTest::SetUp(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and Aleph::tree_decomposition_detail::Rooted_Tree_Topology< GT, SA >::validate_connected_acyclic().

◆ push() [2/2]

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

Push an item by move onto the top of the stack.

Moves data onto the top of the stack, avoiding a copy.

Time complexity: O(1)

Parameters
[in]dataThe item to be moved and pushed.
Returns
A modifiable reference to the newly pushed item.
Exceptions
std::bad_allocIf memory allocation fails.

Definition at line 265 of file tpl_dynListStack.H.

References Aleph::DynList< T >::insert(), and Aleph::DynListStack< T >::s.

◆ put() [1/2]

template<typename T >
T & Aleph::DynListStack< T >::put ( const T &  data)
inline

Alias for push() - for compatibility with queue-like interfaces.

Parameters
[in]dataThe item to put.
Returns
Reference to the newly added item.

Definition at line 307 of file tpl_dynListStack.H.

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

Referenced by Aleph::blossom_weighted_detail::mwmatching::impl::MatchingContext< WeightType >::augment_blossom(), Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::check_blossom(), TEST(), TEST(), TEST(), TEST(), and TEST().

◆ put() [2/2]

template<typename T >
T & Aleph::DynListStack< T >::put ( T &&  data)
inline

See put(const T & data).

Definition at line 310 of file tpl_dynListStack.H.

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

◆ search() [1/2]

template<typename T >
const T * Aleph::DynListStack< T >::search ( const T &  key) const
inlinenoexcept

See search(const T & key).

Definition at line 474 of file tpl_dynListStack.H.

References LocateFunctions< DynListStack< T >, T >::find_ptr().

◆ search() [2/2]

template<typename T >
T * Aleph::DynListStack< T >::search ( const T &  key)
inlinenoexcept

Search for an item in the stack using equality comparison.

Performs a linear search from top to bottom looking for an element equal to key.

Time complexity: O(n)

Parameters
[in]keyThe value to search for.
Returns
Pointer to the item if found, nullptr otherwise.
Warning
The returned pointer is invalidated if the element is removed.

Definition at line 467 of file tpl_dynListStack.H.

References LocateFunctions< DynListStack< T >, T >::find_ptr().

Referenced by Aleph::DynListStack< T >::contains(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST_F().

◆ size()

◆ swap()

template<typename T >
void Aleph::DynListStack< T >::swap ( DynListStack< T > &  other)
inlinenoexcept

Swap the contents of this stack with another.

Exchanges the contents of this stack with those of other in constant time O(1). No elements are copied or moved individually.

Parameters
[in,out]otherThe stack to swap with.
Note
This operation is noexcept and provides the strong exception guarantee (either succeeds completely or has no effect).

Definition at line 135 of file tpl_dynListStack.H.

References Aleph::DynListStack< T >::s, and Aleph::DynList< T >::swap().

Referenced by Aleph::DynListStack< T >::DynListStack(), TEST(), TEST(), TEST(), TEST_F(), TEST_F(), and TEST_F().

◆ top() [1/2]

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

Return a modifiable reference to the top item of the stack.

Provides access to the top element without removing it.

Time complexity: O(1)

Returns
A modifiable reference to the top item.
Exceptions
std::underflow_errorIf the stack is empty.
Warning
The reference is invalidated if the top element is removed.

Definition at line 358 of file tpl_dynListStack.H.

References Aleph::DynList< T >::get_first(), and Aleph::DynListStack< T >::s.

Referenced by Aleph::blossom_weighted_detail::mwmatching::impl::MatchingContext< WeightType >::augment_blossom(), Aleph::Gen_Mo_On_Trees< GT, Policy >::build(), Aleph::Gen_Mo_On_Tree_Node< T, Policy >::build(), Aleph::Gen_Heavy_Light_Decomposition< GT, SA >::build_decomposition(), Aleph::lca_detail::Rooted_Tree_Data< GT, SA >::build_dfs_data(), Aleph::tree_dp_detail::Tree_Topology< GT, SA >::build_order(), Aleph::blossom_weighted_detail::mwmatching::impl::MatchingVerifier< WeightType >::check_blossom(), Aleph::hld_detail::HLD_Tree_Data< GT, SA >::compute_hld_positions(), Aleph::hld_detail::HLD_Tree_Data< GT, SA >::compute_sizes_and_parents(), demo_stack(), Aleph::Lengauer_Tarjan_Dominators< GT, SA >::dfs(), Aleph::DynListStack< T >::peek(), Aleph::DynListStack< T >::peek(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and Aleph::tree_decomposition_detail::Rooted_Tree_Topology< GT, SA >::validate_connected_acyclic().

◆ top() [2/2]

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

Return a const reference to the top item of the stack.

Provides read-only access to the top element without removing it.

Time complexity: O(1)

Returns
A const reference to the top item.
Exceptions
std::underflow_errorIf the stack is empty.

Definition at line 372 of file tpl_dynListStack.H.

References Aleph::DynList< T >::get_first(), and Aleph::DynListStack< T >::s.

◆ traverse() [1/4]

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

See traverse(Operation & operation).

Definition at line 440 of file tpl_dynListStack.H.

References Aleph::DynListStack< T >::s, and GenericTraverse< Container >::traverse().

◆ traverse() [2/4]

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

See traverse(Operation & operation).

Definition at line 449 of file tpl_dynListStack.H.

References Aleph::DynListStack< T >::s, and GenericTraverse< Container >::traverse().

◆ traverse() [3/4]

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

See traverse(Operation & operation).

Definition at line 431 of file tpl_dynListStack.H.

References Aleph::DynListStack< T >::s, and GenericTraverse< Container >::traverse().

◆ traverse() [4/4]

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

Traverse all elements from top to bottom.

Executes operation on each element in LIFO order (top to bottom). The traversal stops early if operation returns false.

Template Parameters
OperationA callable type with signature bool(T&) or bool(const T&).
Parameters
[in]operationThe operation to perform on each element.
Returns
true if operation returned true for all elements; false if traversal was stopped early.
Note
The operation receives elements in the order they would be popped from the stack.

Definition at line 422 of file tpl_dynListStack.H.

References Aleph::DynListStack< T >::s, and GenericTraverse< Container >::traverse().

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

Member Data Documentation

◆ s


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