|
Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
|
Queue implemented with a single dynamic array. More...
#include <tpl_arrayQueue.H>
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 |
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.
FixedStack, which is faster because it does not perform bound_statics checks, Definition at line 79 of file tpl_arrayQueue.H.
| using Aleph::ArrayQueue< T >::Const_Iterator = Aleph::Const_Iterator<Iterator> |
Read-only iterator: the iterator of a constant container.
Definition at line 645 of file tpl_arrayQueue.H.
| using Aleph::ArrayQueue< T >::Item_Type = T |
Type stored in the queue.
Definition at line 120 of file tpl_arrayQueue.H.
|
inline |
Construct a queue with capacity sz
| [in] | sz | initial capacity |
| bad_alloc | if there is no enough memory |
Definition at line 141 of file tpl_arrayQueue.H.
References Aleph::MemArray< T >::disable_annotations().
|
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.
|
inlinenoexcept |
Move constructor.
Definition at line 161 of file tpl_arrayQueue.H.
References Aleph::MemArray< T >::disable_annotations().
|
inline |
Definition at line 169 of file tpl_arrayQueue.H.
|
inline |
Definition at line 169 of file tpl_arrayQueue.H.
|
inline |
Definition at line 169 of file tpl_arrayQueue.H.
|
inline |
See put(const T & item).
Definition at line 289 of file tpl_arrayQueue.H.
References Aleph::ArrayQueue< T >::put().
|
inline |
See put(T && item).
Definition at line 295 of file tpl_arrayQueue.H.
References Aleph::ArrayQueue< T >::put().
|
inlinenoexcept |
See empty().
Definition at line 193 of file tpl_arrayQueue.H.
References Aleph::ArrayQueue< T >::empty().
|
inlineprivatenoexcept |
Definition at line 238 of file tpl_arrayQueue.H.
References Aleph::MemArray< T >::access(), Aleph::ArrayQueue< T >::increase_index(), Aleph::MemArray< T >::n, and Aleph::ArrayQueue< T >::rear_index.
Referenced by Aleph::ArrayQueue< T >::put_item().
|
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().
|
inline |
Empty the queue and reduce storage to Min_Dim.
| std::bad_alloc | or an exception from default construction of T. |
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.
|
inline |
Return the oldest item, in O(1).
| std::underflow_error | if 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().
|
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.
|
inline |
Return the i-th oldest item of the queue.
| [in] | i | position to access |
| range_error | if 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().
|
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.
|
inline |
Remove the oldest item of the queue and return a copy.
| underflow_error | if the queue is empty |
Definition at line 356 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 fill_wrapped(), main(), Aleph::ArrayQueue< T >::pop(), Aleph::ArrayQueue< T >::remove_first(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().
|
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().
|
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().
|
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().
|
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().
|
inline |
Remove the i oldest items of the queue.
| [in] | i | number of items to remove |
| underflow_error | if 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().
|
inlineprivatenoexcept |
Advance a physical index modulo the allocated capacity.
Definition at line 91 of file tpl_arrayQueue.H.
References Aleph::MemArray< T >::dim.
Referenced by Aleph::ArrayQueue< T >::complete_put(), Aleph::ArrayQueue< T >::get(), Aleph::ArrayQueue< T >::getn(), Aleph::ArrayQueue< T >::putn(), Aleph::ArrayQueue< T >::traverse(), and Aleph::ArrayQueue< T >::traverse().
|
inline |
See put(const T & item).
Definition at line 301 of file tpl_arrayQueue.H.
References Aleph::ArrayQueue< T >::put().
|
inline |
See put(T && item).
Definition at line 307 of file tpl_arrayQueue.H.
References Aleph::ArrayQueue< T >::put().
|
inline |
Return the youngest item, in O(1).
| std::underflow_error | if 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().
|
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().
|
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.
|
inlinenoexcept |
Access an item by FIFO position with debug assertions.
| [in] | i | Index satisfying i < size(). |
| 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.
|
inlinenoexcept |
Move assign.
Definition at line 229 of file tpl_arrayQueue.H.
References Aleph::ArrayQueue< T >::front_index, Aleph::ArrayQueue< T >::rear_index, and Aleph::ArrayQueue< T >::swap().
|
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().
|
inline |
Access an item by its FIFO position.
| [in] | i | Zero-based index from the oldest item. |
| std::out_of_range | if i >= size(). |
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.
|
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.
|
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().
|
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().
|
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().
|
inline |
Copy and put an item in the queue.
| [in] | item | to put; it may be an item of this queue, as in q.put(q.front()), even when the queue must grow |
| bad_alloc | if there is no enough memory |
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().
|
inline |
Move an item to the rear of the queue.
| [in] | item | to put; it may be an item of this queue, which is then left moved from |
| bad_alloc | if there is no enough memory |
item is untouched if the allocation throws. Definition at line 283 of file tpl_arrayQueue.H.
References Aleph::ArrayQueue< T >::put_item().
|
inlineprivate |
Shared body of both put() overloads.
Definition at line 248 of file tpl_arrayQueue.H.
References Aleph::MemArray< T >::access(), Aleph::ArrayQueue< T >::complete_put(), Aleph::MemArray< T >::dim, Aleph::ArrayQueue< T >::front_index, Aleph::MemArray< T >::grow_and_insert(), Aleph::MemArray< T >::n, Aleph::ArrayQueue< T >::rear_index, and Aleph::ArrayQueue< T >::recenter_indices().
Referenced by Aleph::ArrayQueue< T >::put(), and Aleph::ArrayQueue< T >::put().
|
inline |
Add sz logical slots at the rear without initializing scalars.
| [in] | sz | Number of slots to add; zero requires a nonempty queue. |
| std::underflow_error | if both sz and size() are zero. |
| std::overflow_error | if sz exceeds twice the effective capacity minus size(); the effective capacity of a moved-from queue is Min_Dim. |
| std::bad_alloc | or an exception from constructing/moving T. |
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().
|
inline |
Return the i-th youngest item of the queue.
| [in] | i | position to access |
| range_error | if 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().
|
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().
|
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.
|
inlineprivatenoexcept |
Access the i-th item counting backwards from the youngest item.
Definition at line 98 of file tpl_arrayQueue.H.
References Aleph::MemArray< T >::access(), Aleph::MemArray< T >::dim, offset, and Aleph::ArrayQueue< T >::rear_index.
Referenced by Aleph::ArrayQueue< T >::putn(), Aleph::ArrayQueue< T >::rear(), Aleph::ArrayQueue< T >::rear(), and Aleph::ArrayQueue< T >::remove_last().
|
inlineprivatenoexcept |
Reset indices after relocating the logical sequence to slot zero.
Definition at line 113 of file tpl_arrayQueue.H.
References Aleph::MemArray< T >::dim, Aleph::ArrayQueue< T >::front_index, Aleph::MemArray< T >::n, and Aleph::ArrayQueue< T >::rear_index.
Referenced by Aleph::ArrayQueue< T >::get(), Aleph::ArrayQueue< T >::getn(), Aleph::ArrayQueue< T >::put_item(), Aleph::ArrayQueue< T >::putn(), Aleph::ArrayQueue< T >::remove_last(), and Aleph::ArrayQueue< T >::reserve().
|
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().
|
inline |
Remove the youngest item.
| std::underflow_error | if empty, or an exception from allocation/T. |
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().
|
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.
| [in] | cap | requested capacity |
| std::bad_alloc | or an exception from constructing/moving T. |
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().
|
inline |
Reverse the logical queue in place.
| Any | exception from swapping T; earlier swaps are not undone. |
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().
|
inlinenoexcept |
Swap this with q
Definition at line 129 of file tpl_arrayQueue.H.
References Aleph::ArrayQueue< T >::front_index, Aleph::ArrayQueue< T >::rear_index, and Aleph::MemArray< T >::swap().
Referenced by Aleph::ArrayQueue< T >::operator=(), Aleph::ArrayQueue< T >::operator=(), and TEST().
|
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().
|
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().
|
inlinenoexcept |
See traverse(Operation & operation).
Definition at line 606 of file tpl_arrayQueue.H.
|
inlinenoexcept |
See traverse(Operation & operation).
Definition at line 615 of file tpl_arrayQueue.H.
|
inlinenoexcept |
See traverse(Operation & operation).
Definition at line 591 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.
|
inlinenoexcept |
Traverse all the elements from the oldest to the youngest and execute operation on each on them.
| [in] | operation | to be performed on each element |
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.
|
private |
Definition at line 87 of file tpl_arrayQueue.H.
Referenced by Aleph::ArrayQueue< T >::empty(), Aleph::ArrayQueue< T >::empty_and_release(), Aleph::ArrayQueue< T >::front(), Aleph::ArrayQueue< T >::front(), Aleph::ArrayQueue< T >::get(), Aleph::ArrayQueue< T >::getn(), Aleph::ArrayQueue< T >::operator()(), Aleph::ArrayQueue< T >::operator()(), Aleph::ArrayQueue< T >::operator=(), Aleph::ArrayQueue< T >::put_item(), Aleph::ArrayQueue< T >::putn(), Aleph::ArrayQueue< T >::recenter_indices(), Aleph::ArrayQueue< T >::remove_last(), Aleph::ArrayQueue< T >::reserve(), Aleph::ArrayQueue< T >::swap(), Aleph::ArrayQueue< T >::traverse(), and Aleph::ArrayQueue< T >::traverse().
|
private |
Definition at line 88 of file tpl_arrayQueue.H.
Referenced by Aleph::ArrayQueue< T >::ArrayQueue(), Aleph::ArrayQueue< T >::complete_put(), Aleph::ArrayQueue< T >::empty(), Aleph::ArrayQueue< T >::empty_and_release(), Aleph::ArrayQueue< T >::operator=(), Aleph::ArrayQueue< T >::put_item(), Aleph::ArrayQueue< T >::putn(), Aleph::ArrayQueue< T >::rear_item(), Aleph::ArrayQueue< T >::rear_item(), Aleph::ArrayQueue< T >::recenter_indices(), Aleph::ArrayQueue< T >::remove_last(), and Aleph::ArrayQueue< T >::swap().