44# ifndef TPL_DYNLISTSTACK_H
45# define TPL_DYNLISTSTACK_H
47# include <type_traits>
229 [[nodiscard]]
size_t size() const noexcept {
return s.
size(); }
267 return s.
insert(std::forward<T>(data));
288 template <
typename... Args>
291 return push(
T(std::forward<Args>(args)...));
310 T &
put(
T && data) {
return push(std::forward<T>(data)); }
372 [[nodiscard]]
const T &
top()
const
387 [[nodiscard]]
const T &
peek()
const {
return top(); }
420 template <
class Operation>
423 noexcept(
noexcept(
s.
traverse(operation)))
429 template <
class Operation>
432 noexcept(
noexcept(
s.
traverse(operation)))
438 template <
class Operation>
440 bool traverse(Operation && operation = Operation()) const
441 noexcept(noexcept(
s.
traverse(operation)))
443 return s.
traverse(std::forward<Operation>(operation));
447 template <
class Operation>
449 bool traverse(Operation && operation = Operation())
450 noexcept(noexcept(
s.
traverse(operation)))
452 return s.
traverse(std::forward<Operation>(operation));
468 noexcept(
noexcept(
static_cast<bool>(std::declval<const T &>() == std::declval<const T &>())))
470 return this->
find_ptr([&key](
const T & item) {
return static_cast<bool>(item == key); });
475 noexcept(
noexcept(
static_cast<bool>(std::declval<const T &>() == std::declval<const T &>())))
477 return this->
find_ptr([&key](
const T & item) {
return static_cast<bool>(item == key); });
488 noexcept(
noexcept(
static_cast<bool>(std::declval<const T &>() == std::declval<const T &>())))
490 return search(key) !=
nullptr;
494 [[nodiscard]]
bool has(
const T & key)
const
495 noexcept(
noexcept(
static_cast<bool>(std::declval<const T &>() == std::declval<const T &>())))
Variadic constructor macros for containers.
STL-compatible iterator adapters for Aleph containers.
DRY (Don't Repeat Yourself) utilities and macros.
#define Special_Ctors(Set_Type, Type)
Generates special constructors for containers.
Iterator traits and STL-compatible iterator wrappers.
Read-only view of an Aleph iterator: the iterator of a constant container.
Dynamic stack of elements of generic type T based on a singly linked list.
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.
T & put(const T &data)
Alias for push() - for compatibility with queue-like interfaces.
DynListStack(const DynListStack &other)
Copy constructor.
void clear() noexcept
Empties the container.
T Key_Type
Alias for Item_Type.
T & top()
Return a modifiable reference to the top item of the stack.
bool is_empty() const noexcept
Check if the stack is empty.
DynListStack() noexcept
Construct an empty stack.
bool has(const T &key) const noexcept(noexcept(static_cast< bool >(std::declval< const T & >()==std::declval< const T & >())))
Alias for contains().
T & insert(const T &data)
Alias for push() - for STL-like insert semantics.
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.
T & emplace(Args &&... args)
Construct an item in place at the top of the stack.
bool traverse(Operation &&operation=Operation()) const noexcept(noexcept(s.traverse(operation)))
See traverse(Operation & operation).
size_t size() const noexcept
Return the number of elements in the stack.
T & peek()
Alias for top() - returns reference to top item.
void swap(DynListStack &other) noexcept
Swap the contents of this stack with another.
T & append(T &&data)
See append(const T & data).
T get()
Alias for pop() - removes and returns the top item.
DynListStack & operator=(const DynListStack &rhs)
Copy assignment operator.
T & append(const T &data)
Alias for push() - required by Special_Ctors macro.
const T & peek() const
Alias for top() const - returns const reference to top item.
T & push(T &&data)
Push an item by move onto the top of the stack.
T Item_Type
The type of elements stored in the stack.
bool traverse(Operation &operation) const noexcept(noexcept(s.traverse(operation)))
See traverse(Operation & operation).
DynListStack(DynListStack &&other) noexcept
Move constructor.
bool traverse(Operation &operation) noexcept(noexcept(s.traverse(operation)))
Traverse all elements from top to bottom.
T & insert(T &&data)
See insert(const T & data).
T pop()
Remove and return the top item of the stack.
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).
T & put(T &&data)
See put(const T & data).
T & push(const T &data)
Push an item by copy onto the top of the stack.
bool traverse(Operation &&operation=Operation()) noexcept(noexcept(s.traverse(operation)))
See traverse(Operation & operation).
const T & top() const
Return a const reference to the top item of the stack.
void empty() noexcept
Remove all elements from the stack.
Iterator on the items of list.
Doubly-linked list (defined in tpl_dynList.H).
T & get_first()
Return the first item of the list.
T & insert(const T &item)
T remove_first()
See remove().
size_t size() const noexcept
Return the number of items of the list, in constant time.
void empty() noexcept
empty the list
DynList & swap(DynList &l) noexcept
constexpr bool is_empty() const noexcept
Mixin providing equality comparison for sequence containers.
Common methods to the Aleph-w ( ) containers.
Common sequential searching methods on containers.
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.
Mixin that adds STL begin()/end() and cbegin()/cend() to Aleph containers.
f(args...) is a valid call whose result is usable as a condition.
Singly linked list implementations with head-tail access.
Main namespace for Aleph-w library functions.
std::decay_t< typename HeadC::Item_Type > T
Iterator for traversing elements of the stack.
Iterator(const DynListStack< T > &)=delete
A constant stack is iterated through Const_Iterator.
Iterator(DynListStack< T > &stack) noexcept
Construct an iterator for a stack.
typename DynList< T >::Iterator Base
Base iterator type.
Generic list of items stored in a container.
bool traverse(Operation &operation) noexcept(traverse_is_noexcept< Operation, typename Aleph::concepts_detail::traverse_arg< Container, Operation >::type, Container & >())
Traverse the container via its iterator and performs a conditioned operation on each item.