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

Queue implemented with a single dynamic array. More...

#include <tpl_arrayQueue.H>

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

Classes

struct  Iterator
 Simple iterator on elements of a queue. More...
 

Public Types

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

Public Member Functions

void swap (ArrayQueue &q) noexcept
 Swap this with q
 
 ArrayQueue (const size_t sz=8)
 Construct a queue with capacity sz
 
 ArrayQueue (const ArrayQueue &q)
 Copy constructor.
 
 ArrayQueue (ArrayQueue &&q) noexcept
 Move constructor.
 
template<template< typename > class List>
 ArrayQueue (const List< T > &l)
 
template<class It >
requires (not std::is_arithmetic_v<It> and requires (It it) { *it; ++it; it != it; })
 ArrayQueue (It b, It e)
 
 ArrayQueue (std::initializer_list< T > l)
 
ArrayQueue & operator= (const ArrayQueue &q)
 Copy assign (copy and swap: same queue order as the copy constructor)
 
void empty () noexcept
 Empty the queue keeping its capacity; both ends restart at slot 0.
 
void clear () noexcept
 See empty().
 
void empty_and_release ()
 Empty the queue and reduce storage to Min_Dim.
 
void reserve (const size_t cap)
 Reserve capacity for at least cap items, keeping the queue order.
 
ArrayQueue & operator= (ArrayQueue &&q) noexcept
 Move assign.
 
T & put (const T &item)
 Copy and put an item in the queue.
 
T & put (T &&item)
 Move an item to the rear of the queue.
 
T & append (const T &item)
 See put(const T & item).
 
T & append (T &&item)
 See put(T && item).
 
T & insert (const T &item)
 See put(const T & item).
 
T & insert (T &&item)
 See put(T && item).
 
T & putn (const size_t sz)
 Add sz logical slots at the rear without initializing scalars.
 
T get ()
 Remove the oldest item of the queue and return a copy.
 
T & getn (const size_t i)
 Remove the i oldest items of the queue.
 
T & front (const size_t i=0)
 Return the i-th oldest item of the queue.
 
const T & front (const size_t i=0) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. A reference to const.
 
T & rear (const size_t i=0)
 Return the i-th youngest item of the queue.
 
const T & rear (const size_t i=0) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. A reference to const.
 
T & operator[] (const size_t i)
 Access an item by its FIFO position.
 
const T & operator[] (const size_t i) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. A reference to const.
 
T & operator() (const size_t i) noexcept
 Access an item by FIFO position with debug assertions.
 
const T & operator() (const size_t i) const noexcept
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. A reference to const.
 
T & first ()
 Return the oldest item, in O(1).
 
const T & first () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. A reference to const.
 
T & last ()
 Return the youngest item, in O(1).
 
const T & last () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. A reference to const.
 
T & get_first ()
 Alias for first(); throws std::underflow_error if empty.
 
const T & get_first () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. A reference to const.
 
T & get_last ()
 Alias for last(); throws std::underflow_error if empty.
 
const T & get_last () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. A reference to const.
 
T & top ()
 Alias for first(); throws std::underflow_error if empty.
 
const T & top () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. A reference to const.
 
T remove_first ()
 Remove the oldest item; same complexity and exceptions as get().
 
T pop ()
 Alias for get(); remove the oldest item in FIFO order.
 
T & push (const T &item)
 Alias for put(); enqueue a copy at the rear.
 
T & push (T &&item)
 Alias for put(); enqueue an item by moving it at the rear.
 
T remove_last ()
 Remove the youngest item.
 
ArrayQueue & reverse ()
 Reverse the logical queue in place.
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, T &>
bool traverse (Operation &operation) noexcept(Aleph::NothrowPredicateWith< Operation &, T & >)
 Traverse all the elements from the oldest to the youngest and execute operation on each on them.
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, const T &>
bool traverse (Operation &operation) const noexcept(Aleph::NothrowPredicateWith< Operation &, const T & >)
 See traverse(Operation & operation).
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, const T &>
bool traverse (Operation &&operation) const noexcept(Aleph::NothrowPredicateWith< Operation &, const T & >)
 See traverse(Operation & operation).
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, T &>
bool traverse (Operation &&operation) noexcept(Aleph::NothrowPredicateWith< Operation &, T & >)
 See traverse(Operation & operation).
 
- Public Member Functions inherited from LocateFunctions< ArrayQueue< 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< ArrayQueue< 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< ArrayQueue< 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< ArrayQueue< 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< ArrayQueue< 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< ArrayQueue< 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< ArrayQueue< 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< ArrayQueue< 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< ArrayQueue< 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< ArrayQueue< 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< ArrayQueue< T > >
bool equal_to (const ArrayQueue< T > &r) const
 Equality test between this and r.
 
- Public Member Functions inherited from StlAlephIterator< ArrayQueue< 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 Member Functions

void increase_index (size_t &i, const size_t inc=1) const noexcept
 Advance a physical index modulo the allocated capacity.
 
T & rear_item (const size_t i=0) noexcept
 Access the i-th item counting backwards from the youngest item.
 
const T & rear_item (const size_t i=0) const noexcept
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. A reference to const.
 
void recenter_indices () noexcept
 Reset indices after relocating the logical sequence to slot zero.
 
T & complete_put () noexcept
 
template<class U >
T & put_item (U &&item)
 Shared body of both put() overloads.
 

Private Attributes

size_t front_index
 
size_t rear_index
 

Additional Inherited Members

- Static Public Member Functions inherited from FunctionalMethods< ArrayQueue< T >, T >
static ArrayQueue< 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< ArrayQueue< 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.
 
- Protected Types inherited from Aleph::MemArray< T >
using Item_Type = T
 
using Const_Iterator = Aleph::Const_Iterator< Iterator >
 Read-only iterator: the iterator of a constant container.
 
- Protected Types inherited from StlAlephIterator< ArrayQueue< T > >
using iterator = StlIterator< ArrayQueue< T > >
 
using const_iterator = StlConstIterator< ArrayQueue< T > >
 
- Protected Member Functions inherited from Aleph::MemArray< T >
void annotate (const size_t old_n, const size_t new_n) const noexcept
 Tell AddressSanitizer that the live items, previously the prefix [0, old_n), are now [0, new_n): accesses to the slots in [new_n, dim) are then reported as container-overflow.
 
void disable_annotations () noexcept
 Make the whole buffer accessible and stop annotating it.
 
void allocate ()
 Allocate memory for the current dimension.
 
void reallocate (const size_t cap, const size_t first=0)
 Relocate the logical sequence into a new buffer.
 
bool expand (const size_t first=0)
 Grow a full array, including an empty moved-from array.
 
template<class U >
T & relocate_and_insert (const size_t pos, U &&item, const size_t first)
 Grow a full array and insert one item into the new buffer.
 
template<class U >
T & grow_and_insert (const size_t pos, U &&item, const size_t first=0)
 Grow a full array and insert one item: relocate_and_insert().
 
bool contract (const size_t first=0)
 Test if n is lesser than contract_threshold and eventually contract the array half long and copies its content.
 
void init_dim (size_t d)
 Initialize the dimension of the array to d or to the next two power if d is not a two power.
 
T * get_ptr () noexcept
 Return the current base of array.
 
const T * get_ptr () const noexcept
 See get_ptr().
 
const size_t & get_dim () const noexcept
 Return the current dimension of array.
 
constexpr size_t capacity () const noexcept
 The type of element of array.
 
size_t size () const noexcept
 Return the number of elements.
 
bool is_empty () const noexcept
 Return true is the array is empty.
 
 MemArray (size_t _dim=Min_Dim)
 Construct an array con capacity equal or greater than _dim.
 
 ~MemArray ()
 
void swap (MemArray &a) noexcept
 Swap in constant time this with a
 
 MemArray (const MemArray &a)
 Construct a copy of a, with its capacity.
 
 MemArray (MemArray &&a) noexcept
 Transfer storage without allocation.
 
MemArray & operator= (const MemArray &a)
 Assign by copy a to this
 
MemArray & operator= (MemArray &&a) noexcept
 Assign by moving a to this
 
void empty () noexcept
 Empties the container.
 
void clear () noexcept
 Alias for empty().
 
void empty_and_release ()
 Clear the array and reduce allocated storage to Min_Dim.
 
T & put (const T &item)
 Put a copy of item at the end of the sequence.
 
T & put (T &&item)
 Move item to the end of the sequence.
 
T & push (const T &item)
 Push a copy of item at the beginning of the sequence.
 
T & push (T &&item)
 Move item to the beginning of the sequence.
 
T & top ()
 
const T & top () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. A reference to const.
 
T remove_first ()
 Remove the first item. Gap is closed.
 
T pop ()
 pop() the most recently pushed item
 
T & append (const T &item)
 See put(const T & item).
 
T & append (T &&item)
 See put(T && item).
 
T & insert (const T &item)
 See push(const T & item).
 
T & insert (T &&item)
 See push(T && item).
 
void putn (const size_t more)
 Reserve more additional logical slots in the array.
 
MemArray & append (const MemArray &a)
 
void reserve (const size_t cap)
 Reserves cap cells into the array.
 
T get (const size_t i=1)
 Remove i elements from the end.
 
T get_ne (const size_t i=1) noexcept
 
T remove_last ()
 See get().
 
T & last ()
 Return a modifiable reference to the last element.
 
const T & last () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. A reference to const.
 
T & first ()
 Return a modifiable reference to the first element.
 
const T & first () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. A reference to const.
 
T & get_first ()
 See first.
 
const T & get_first () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. A reference to const.
 
T & get_last ()
 See last.
 
const T & get_last () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. A reference to const.
 
MemArray & reverse ()
 Reverse the order of items in array.
 
T & access (const size_t i) noexcept
 Return a modifiable reference to the ith element.
 
const T & access (const size_t i) const noexcept
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. A reference to const.
 
T & operator[] (const size_t i)
 Return a reference to the ith element.
 
const T & operator[] (const size_t i) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. A reference to const.
 
T & operator() (const size_t i) noexcept
 Unlike access(), which also reaches the reserved slots beyond the logical size (a build with AddressSanitizer and ALEPH_ANNOTATE_CONTAINERS reports that), debug builds assert that i is a live item (i < n).
 
const T & operator() (const size_t i) const noexcept
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. A reference to const.
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, T &>
bool traverse (Operation &operation) noexcept(Aleph::NothrowPredicateWith< Operation &, T & >)
 Traverse all the elements from index 0 to n - 1 and execute operation on each on them.
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, const T &>
bool traverse (Operation &operation) const noexcept(Aleph::NothrowPredicateWith< Operation &, const T & >)
 Traverse a constant array; each element is handed out as a constant reference.
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, const T &>
bool traverse (Operation &&operation) const noexcept(Aleph::NothrowPredicateWith< Operation &, const T & >)
 See traverse(Operation & operation) const.
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, T &>
bool traverse (Operation &&operation) noexcept(Aleph::NothrowPredicateWith< Operation &, T & >)
 See traverse(Operation & operation).
 
bool is_valid () const noexcept
 
- Protected Member Functions inherited from LocateFunctions< ArrayQueue< 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< ArrayQueue< 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< ArrayQueue< 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< ArrayQueue< 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.
 
- Protected Member Functions inherited from FunctionalMethods< ArrayQueue< 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< ArrayQueue< 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< ArrayQueue< 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< ArrayQueue< 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< ArrayQueue< 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< ArrayQueue< 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.
 
- Protected 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().
 
- Protected Member Functions inherited from EqualSequenceMethod< ArrayQueue< T > >
bool equal_to (const ArrayQueue< T > &r) const
 Equality test between this and r.
 
- Protected Member Functions inherited from StlAlephIterator< ArrayQueue< 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.
 
- Static Protected Member Functions inherited from Aleph::MemArray< T >
static size_t next_power_of_two (const size_t requested)
 
- Static Protected Member Functions inherited from FunctionalMethods< ArrayQueue< T >, T >
static ArrayQueue< 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.
 
- Protected Attributes inherited from Aleph::MemArray< T >
T * ptr = nullptr
 
size_t dim = Min_Dim
 
size_t n = 0
 
size_t contract_threshold
 Number of items at or below which contract() halves the capacity.
 
- Protected Attributes inherited from FunctionalMethods< ArrayQueue< 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.
 
- Static Protected Attributes inherited from Aleph::MemArray< T >
static constexpr bool copied_as_bytes
 Whether memcpy() copies an item as its assignments do: T is trivially copyable, its copy and move assignments are trivial, and it is not volatile, whose pointers memcpy() does not take.
 
static constexpr size_t Min_Dim = 4
 

Detailed Description

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

Queue implemented with a single dynamic array.

ArrayQueue<T> represents a queue if elements of generic type T which is stored in single dynamic. In this queue, modifiying operations test arrays bounds.

The array is allocated with new operator and dynamically grows according to the size.

Note
MemArray is an implementation detail, inherited protectedly. Public indexing and first/last access use FIFO order. Raw buffer access and conversion to MemArray are intentionally unavailable.
If you are sure of knowing the bounds, then use FixedStack, which is faster because it does not perform bound_statics checks,

Definition at line 79 of file tpl_arrayQueue.H.

Member Typedef Documentation

◆ Const_Iterator

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

Definition at line 645 of file tpl_arrayQueue.H.

◆ Item_Type

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

Type stored in the queue.

Definition at line 120 of file tpl_arrayQueue.H.

Constructor & Destructor Documentation

◆ ArrayQueue() [1/6]

template<typename T >
Aleph::ArrayQueue< T >::ArrayQueue ( const size_t  sz = 8)
inline

Construct a queue with capacity sz

Parameters
[in]szinitial capacity
Exceptions
bad_allocif there is no enough memory

Definition at line 141 of file tpl_arrayQueue.H.

References Aleph::MemArray< T >::disable_annotations().

◆ ArrayQueue() [2/6]

template<typename T >
Aleph::ArrayQueue< T >::ArrayQueue ( const ArrayQueue< T > &  q)
inline

Copy constructor.

The copy stores the items of q in queue order from slot 0, whatever the front position of q is: copying the raw buffer prefix would lose the items of a queue that has wrapped around.

Definition at line 149 of file tpl_arrayQueue.H.

References Aleph::MemArray< T >::access(), Aleph::MemArray< T >::dim, Aleph::MemArray< T >::disable_annotations(), Aleph::MemArray< T >::n, and Aleph::ArrayQueue< T >::rear_index.

◆ ArrayQueue() [3/6]

template<typename T >
Aleph::ArrayQueue< T >::ArrayQueue ( ArrayQueue< T > &&  q)
inlinenoexcept

Move constructor.

Definition at line 161 of file tpl_arrayQueue.H.

References Aleph::MemArray< T >::disable_annotations().

◆ ArrayQueue() [4/6]

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

Definition at line 169 of file tpl_arrayQueue.H.

◆ ArrayQueue() [5/6]

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

Definition at line 169 of file tpl_arrayQueue.H.

◆ ArrayQueue() [6/6]

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

Definition at line 169 of file tpl_arrayQueue.H.

Member Function Documentation

◆ append() [1/2]

template<typename T >
T & Aleph::ArrayQueue< T >::append ( const T &  item)
inline

See put(const T & item).

Definition at line 289 of file tpl_arrayQueue.H.

References Aleph::ArrayQueue< T >::put().

◆ append() [2/2]

template<typename T >
T & Aleph::ArrayQueue< T >::append ( T &&  item)
inline

See put(T && item).

Definition at line 295 of file tpl_arrayQueue.H.

References Aleph::ArrayQueue< T >::put().

◆ clear()

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

See empty().

Definition at line 193 of file tpl_arrayQueue.H.

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

Referenced by TEST(), and TEST().

◆ complete_put()

template<typename T >
T & Aleph::ArrayQueue< T >::complete_put ( )
inlineprivatenoexcept

◆ empty()

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

Empty the queue keeping its capacity; both ends restart at slot 0.

Definition at line 185 of file tpl_arrayQueue.H.

References Aleph::MemArray< T >::empty(), Aleph::ArrayQueue< T >::front_index, and Aleph::ArrayQueue< T >::rear_index.

Referenced by Aleph::ArrayQueue< T >::clear(), TEST(), and TEST().

◆ empty_and_release()

template<typename T >
void Aleph::ArrayQueue< T >::empty_and_release ( )
inline

Empty the queue and reduce storage to Min_Dim.

Exceptions
std::bad_allocor an exception from default construction of T.
Note
Both ends restart at slot zero. Failure leaves the queue unchanged.

Definition at line 202 of file tpl_arrayQueue.H.

References Aleph::MemArray< T >::empty_and_release(), Aleph::ArrayQueue< T >::front_index, and Aleph::ArrayQueue< T >::rear_index.

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

◆ first() [1/2]

template<typename T >
T & Aleph::ArrayQueue< T >::first ( )
inline

Return the oldest item, in O(1).

Returns
Modifiable reference to the front item.
Exceptions
std::underflow_errorif empty.

Definition at line 477 of file tpl_arrayQueue.H.

References ah_underflow_error_if, Aleph::ArrayQueue< T >::front(), and Aleph::MemArray< T >::n.

Referenced by Aleph::ArrayQueue< T >::get_first(), Aleph::ArrayQueue< T >::get_first(), TEST(), Aleph::ArrayQueue< T >::top(), and Aleph::ArrayQueue< T >::top().

◆ first() [2/2]

template<typename T >
const T & Aleph::ArrayQueue< T >::first ( ) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. A reference to const.

Definition at line 485 of file tpl_arrayQueue.H.

References ah_underflow_error_if, Aleph::ArrayQueue< T >::front(), and Aleph::MemArray< T >::n.

◆ front() [1/2]

template<typename T >
T & Aleph::ArrayQueue< T >::front ( const size_t  i = 0)
inline

Return the i-th oldest item of the queue.

Parameters
[in]iposition to access
Returns
a modifiable reference to the oldest i-th item of the queue
Exceptions
range_errorif i is greater than the number of items

Definition at line 395 of file tpl_arrayQueue.H.

References Aleph::MemArray< T >::access(), ah_range_error_if, Aleph::MemArray< T >::dim, Aleph::ArrayQueue< T >::front_index, and Aleph::MemArray< T >::n.

Referenced by expect_order(), Aleph::ArrayQueue< T >::first(), Aleph::ArrayQueue< T >::first(), Aleph::ArrayQueue< T >::operator[](), Aleph::ArrayQueue< T >::operator[](), print(), Aleph::ArrayQueue< T >::reverse(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().

◆ front() [2/2]

template<typename T >
const T & Aleph::ArrayQueue< T >::front ( const size_t  i = 0) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. A reference to const.

Definition at line 404 of file tpl_arrayQueue.H.

References Aleph::MemArray< T >::access(), ah_range_error_if, Aleph::MemArray< T >::dim, Aleph::ArrayQueue< T >::front_index, and Aleph::MemArray< T >::n.

◆ get()

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

◆ get_first() [1/2]

template<typename T >
T & Aleph::ArrayQueue< T >::get_first ( )
inline

Alias for first(); throws std::underflow_error if empty.

Definition at line 510 of file tpl_arrayQueue.H.

References Aleph::ArrayQueue< T >::first().

Referenced by TEST().

◆ get_first() [2/2]

template<typename T >
const T & Aleph::ArrayQueue< T >::get_first ( ) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. A reference to const.

Definition at line 513 of file tpl_arrayQueue.H.

References Aleph::ArrayQueue< T >::first().

◆ get_last() [1/2]

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

Alias for last(); throws std::underflow_error if empty.

Definition at line 516 of file tpl_arrayQueue.H.

References Aleph::ArrayQueue< T >::last().

Referenced by TEST().

◆ get_last() [2/2]

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

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. A reference to const.

Definition at line 519 of file tpl_arrayQueue.H.

References Aleph::ArrayQueue< T >::last().

◆ getn()

template<typename T >
T & Aleph::ArrayQueue< T >::getn ( const size_t  i)
inline

Remove the i oldest items of the queue.

Parameters
[in]inumber of items to remove
Returns
a modifiable reference to the oldest remaining item
Exceptions
underflow_errorif i is greater than the number of items

Definition at line 376 of file tpl_arrayQueue.H.

References Aleph::MemArray< T >::access(), ah_underflow_error_if, Aleph::MemArray< T >::contract(), Aleph::ArrayQueue< T >::front_index, Aleph::ArrayQueue< T >::increase_index(), Aleph::MemArray< T >::n, and Aleph::ArrayQueue< T >::recenter_indices().

Referenced by main(), and TEST().

◆ increase_index()

template<typename T >
void Aleph::ArrayQueue< T >::increase_index ( size_t &  i,
const size_t  inc = 1 
) const
inlineprivatenoexcept

◆ insert() [1/2]

template<typename T >
T & Aleph::ArrayQueue< T >::insert ( const T &  item)
inline

See put(const T & item).

Definition at line 301 of file tpl_arrayQueue.H.

References Aleph::ArrayQueue< T >::put().

◆ insert() [2/2]

template<typename T >
T & Aleph::ArrayQueue< T >::insert ( T &&  item)
inline

See put(T && item).

Definition at line 307 of file tpl_arrayQueue.H.

References Aleph::ArrayQueue< T >::put().

◆ last() [1/2]

template<typename T >
T & Aleph::ArrayQueue< T >::last ( )
inline

Return the youngest item, in O(1).

Returns
Modifiable reference to the rear item.
Exceptions
std::underflow_errorif empty.

Definition at line 495 of file tpl_arrayQueue.H.

References ah_underflow_error_if, Aleph::MemArray< T >::n, and Aleph::ArrayQueue< T >::rear().

Referenced by Aleph::ArrayQueue< T >::get_last(), Aleph::ArrayQueue< T >::get_last(), and TEST().

◆ last() [2/2]

template<typename T >
const T & Aleph::ArrayQueue< T >::last ( ) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. A reference to const.

Definition at line 503 of file tpl_arrayQueue.H.

References ah_underflow_error_if, Aleph::MemArray< T >::n, and Aleph::ArrayQueue< T >::rear().

◆ operator()() [1/2]

template<typename T >
const T & Aleph::ArrayQueue< T >::operator() ( const size_t  i) const
inlinenoexcept

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. A reference to const.

Definition at line 467 of file tpl_arrayQueue.H.

References Aleph::MemArray< T >::access(), Aleph::MemArray< T >::dim, Aleph::ArrayQueue< T >::front_index, and Aleph::MemArray< T >::n.

◆ operator()() [2/2]

template<typename T >
T & Aleph::ArrayQueue< T >::operator() ( const size_t  i)
inlinenoexcept

Access an item by FIFO position with debug assertions.

Parameters
[in]iIndex satisfying i < size().
Returns
Modifiable reference to the item.
Note
O(1); no range check in Release builds.
Exceptions
Nothing.

Definition at line 459 of file tpl_arrayQueue.H.

References Aleph::MemArray< T >::access(), Aleph::MemArray< T >::dim, Aleph::ArrayQueue< T >::front_index, and Aleph::MemArray< T >::n.

◆ operator=() [1/2]

template<typename T >
ArrayQueue & Aleph::ArrayQueue< T >::operator= ( ArrayQueue< T > &&  q)
inlinenoexcept

◆ operator=() [2/2]

template<typename T >
ArrayQueue & Aleph::ArrayQueue< T >::operator= ( const ArrayQueue< T > &  q)
inline

Copy assign (copy and swap: same queue order as the copy constructor)

Definition at line 172 of file tpl_arrayQueue.H.

References Aleph::copy(), and Aleph::ArrayQueue< T >::swap().

◆ operator[]() [1/2]

template<typename T >
T & Aleph::ArrayQueue< T >::operator[] ( const size_t  i)
inline

Access an item by its FIFO position.

Parameters
[in]iZero-based index from the oldest item.
Returns
Modifiable reference to the item.
Exceptions
std::out_of_rangeif i >= size().
Note
O(1).

Definition at line 439 of file tpl_arrayQueue.H.

References ah_out_of_range_error_if, Aleph::ArrayQueue< T >::front(), and Aleph::MemArray< T >::n.

◆ operator[]() [2/2]

template<typename T >
const T & Aleph::ArrayQueue< T >::operator[] ( const size_t  i) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. A reference to const.

Definition at line 447 of file tpl_arrayQueue.H.

References ah_out_of_range_error_if, Aleph::ArrayQueue< T >::front(), and Aleph::MemArray< T >::n.

◆ pop()

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

Alias for get(); remove the oldest item in FIFO order.

Definition at line 531 of file tpl_arrayQueue.H.

References Aleph::ArrayQueue< T >::get().

Referenced by TEST().

◆ push() [1/2]

template<typename T >
T & Aleph::ArrayQueue< T >::push ( const T &  item)
inline

Alias for put(); enqueue a copy at the rear.

Definition at line 534 of file tpl_arrayQueue.H.

References Aleph::ArrayQueue< T >::put().

Referenced by TEST().

◆ push() [2/2]

template<typename T >
T & Aleph::ArrayQueue< T >::push ( T &&  item)
inline

Alias for put(); enqueue an item by moving it at the rear.

Definition at line 537 of file tpl_arrayQueue.H.

References Aleph::ArrayQueue< T >::put().

◆ put() [1/2]

template<typename T >
T & Aleph::ArrayQueue< T >::put ( const T &  item)
inline

Copy and put an item in the queue.

Parameters
[in]itemto put; it may be an item of this queue, as in q.put(q.front()), even when the queue must grow
Returns
a modifiable reference to the copied item
Exceptions
bad_allocif there is no enough memory
Note
The queue is unchanged if the allocation or the copy throws.

Definition at line 270 of file tpl_arrayQueue.H.

References Aleph::ArrayQueue< T >::put_item().

Referenced by SimpleQueue::SimpleQueue(), Aleph::ArrayQueue< T >::append(), Aleph::ArrayQueue< T >::append(), create_queue(), fill_wrapped(), Aleph::ArrayQueue< T >::insert(), Aleph::ArrayQueue< T >::insert(), main(), Aleph::ArrayQueue< T >::push(), Aleph::ArrayQueue< T >::push(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().

◆ put() [2/2]

template<typename T >
T & Aleph::ArrayQueue< T >::put ( T &&  item)
inline

Move an item to the rear of the queue.

Parameters
[in]itemto put; it may be an item of this queue, which is then left moved from
Returns
a modifiable reference to the moved item
Exceptions
bad_allocif there is no enough memory
Note
item is untouched if the allocation throws.

Definition at line 283 of file tpl_arrayQueue.H.

References Aleph::ArrayQueue< T >::put_item().

◆ put_item()

◆ putn()

template<typename T >
T & Aleph::ArrayQueue< T >::putn ( const size_t  sz)
inline

Add sz logical slots at the rear without initializing scalars.

Parameters
[in]szNumber of slots to add; zero requires a nonempty queue.
Returns
Reference to the youngest item after growth.
Exceptions
std::underflow_errorif both sz and size() are zero.
std::overflow_errorif sz exceeds twice the effective capacity minus size(); the effective capacity of a moved-from queue is Min_Dim.
std::bad_allocor an exception from constructing/moving T.
Note
O(1) without reallocation; O(capacity()) otherwise. Initialize new scalar slots through front(i) or operator[] before reading.

Definition at line 323 of file tpl_arrayQueue.H.

References ah_overflow_error_if, ah_underflow_error_if, FunctionalMethods< ArrayQueue< T >, T >::and, Aleph::MemArray< T >::dim, Aleph::MemArray< T >::expand(), Aleph::ArrayQueue< T >::front_index, Aleph::ArrayQueue< T >::increase_index(), Aleph::MemArray< T >::Min_Dim, Aleph::MemArray< T >::n, Aleph::ArrayQueue< T >::rear_index, Aleph::ArrayQueue< T >::rear_item(), and Aleph::ArrayQueue< T >::recenter_indices().

Referenced by TEST().

◆ rear() [1/2]

template<typename T >
T & Aleph::ArrayQueue< T >::rear ( const size_t  i = 0)
inline

Return the i-th youngest item of the queue.

Parameters
[in]iposition to access
Returns
a modifiable reference to the i-th youngest item of the queue
Exceptions
range_errorif i is greater than the number of items

Definition at line 417 of file tpl_arrayQueue.H.

References ah_range_error_if, Aleph::MemArray< T >::n, and Aleph::ArrayQueue< T >::rear_item().

Referenced by Aleph::ArrayQueue< T >::last(), Aleph::ArrayQueue< T >::last(), main(), print(), Aleph::ArrayQueue< T >::reverse(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().

◆ rear() [2/2]

template<typename T >
const T & Aleph::ArrayQueue< T >::rear ( const size_t  i = 0) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. A reference to const.

Definition at line 426 of file tpl_arrayQueue.H.

References ah_range_error_if, Aleph::MemArray< T >::n, and Aleph::ArrayQueue< T >::rear_item().

◆ rear_item() [1/2]

template<typename T >
const T & Aleph::ArrayQueue< T >::rear_item ( const size_t  i = 0) const
inlineprivatenoexcept

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. A reference to const.

Definition at line 106 of file tpl_arrayQueue.H.

References Aleph::MemArray< T >::access(), Aleph::MemArray< T >::dim, offset, and Aleph::ArrayQueue< T >::rear_index.

◆ rear_item() [2/2]

template<typename T >
T & Aleph::ArrayQueue< T >::rear_item ( const size_t  i = 0)
inlineprivatenoexcept

◆ recenter_indices()

◆ remove_first()

template<typename T >
T Aleph::ArrayQueue< T >::remove_first ( )
inline

Remove the oldest item; same complexity and exceptions as get().

Definition at line 528 of file tpl_arrayQueue.H.

References Aleph::ArrayQueue< T >::get().

Referenced by TEST().

◆ remove_last()

template<typename T >
T Aleph::ArrayQueue< T >::remove_last ( )
inline

Remove the youngest item.

Returns
The removed item, moved from the rear.
Exceptions
std::underflow_errorif empty, or an exception from allocation/T.
Note
O(1) amortized; O(capacity()) if storage contracts.

Definition at line 544 of file tpl_arrayQueue.H.

References ah_underflow_error_if, Aleph::MemArray< T >::contract(), Aleph::MemArray< T >::dim, Aleph::ArrayQueue< T >::front_index, Aleph::MemArray< T >::n, Aleph::ArrayQueue< T >::rear_index, Aleph::ArrayQueue< T >::rear_item(), and Aleph::ArrayQueue< T >::recenter_indices().

Referenced by TEST(), and TEST().

◆ reserve()

template<typename T >
void Aleph::ArrayQueue< T >::reserve ( const size_t  cap)
inline

Reserve capacity for at least cap items, keeping the queue order.

Unlike MemArray::reserve(), which copies the raw buffer prefix, the items are moved in queue order from slot 0.

Parameters
[in]caprequested capacity
Exceptions
std::bad_allocor an exception from constructing/moving T.
Note
O(cap + size()) time. References are invalidated on growth. A throwing move may leave some elements moved from.

Definition at line 219 of file tpl_arrayQueue.H.

References Aleph::MemArray< T >::dim, Aleph::ArrayQueue< T >::front_index, Aleph::MemArray< T >::reallocate(), and Aleph::ArrayQueue< T >::recenter_indices().

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

◆ reverse()

template<typename T >
ArrayQueue & Aleph::ArrayQueue< T >::reverse ( )
inline

Reverse the logical queue in place.

Returns
This queue with FIFO order reversed.
Exceptions
Anyexception from swapping T; earlier swaps are not undone.
Note
O(size()) time, O(1) auxiliary space.

Definition at line 560 of file tpl_arrayQueue.H.

References Aleph::ArrayQueue< T >::front(), Aleph::MemArray< T >::n, and Aleph::ArrayQueue< T >::rear().

Referenced by TEST().

◆ swap()

template<typename T >
void Aleph::ArrayQueue< T >::swap ( ArrayQueue< T > &  q)
inlinenoexcept

◆ top() [1/2]

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

Alias for first(); throws std::underflow_error if empty.

Definition at line 522 of file tpl_arrayQueue.H.

References Aleph::ArrayQueue< T >::first().

Referenced by TEST().

◆ top() [2/2]

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

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. A reference to const.

Definition at line 525 of file tpl_arrayQueue.H.

References Aleph::ArrayQueue< T >::first().

◆ traverse() [1/4]

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

See traverse(Operation & operation).

Definition at line 606 of file tpl_arrayQueue.H.

◆ traverse() [2/4]

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

See traverse(Operation & operation).

Definition at line 615 of file tpl_arrayQueue.H.

◆ traverse() [3/4]

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

◆ traverse() [4/4]

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

Traverse all the elements from the oldest to the youngest and execute operation on each on them.

Parameters
[in]operationto be performed on each element
Returns
true if operation was executed on all elements; false otherwise.

Definition at line 576 of file tpl_arrayQueue.H.

References Aleph::MemArray< T >::access(), Aleph::ArrayQueue< T >::front_index, Aleph::ArrayQueue< T >::increase_index(), and Aleph::MemArray< T >::n.

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

Member Data Documentation

◆ front_index

◆ rear_index


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