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

Lightweight wrapper that provides Aleph-w container interface for raw arrays. More...

#include <array_it.H>

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

Classes

struct  Iterator
 Iterator type for Array_Container. More...
 

Public Types

using Item_Type = T
 The type of elements in the container.
 
- Public Types inherited from StlAlephIterator< Array_Container< T > >
using iterator = StlIterator< Array_Container< T > >
 
using const_iterator = StlConstIterator< Array_Container< T > >
 

Public Member Functions

T * get_base () const noexcept
 Get the base pointer.
 
 Array_Container (T *base_ptr, const size_t d)
 Construct a container wrapping a raw array.
 
constexpr bool is_empty () const noexcept
 Check if the container is empty.
 
constexpr size_t size () const noexcept
 Get the number of elements.
 
constexpr size_t capacity () const noexcept
 Get the capacity.
 
T & get_first () const
 Get the first element.
 
T & get_last () const
 Get the last element.
 
Iterator get_it () const
 Get an iterator to the beginning.
 
- Public Member Functions inherited from GenericTraverse< Array_Container< T > >
bool traverse (Operation &operation) noexcept(traverse_is_noexcept< Operation, typename Aleph::concepts_detail::traverse_arg< Array_Container< T >, Operation >::type, Array_Container< T > & >())
 Traverse the container via its iterator and performs a conditioned operation on each item.
 
bool traverse (Operation &operation) const noexcept(traverse_is_noexcept< Operation, typename Aleph::concepts_detail::traverse_carg< Array_Container< T >, Operation >::type, const_source_t< Operation > >())
 Traverse a constant container; each item is handed out as a constant reference.
 
bool traverse (Operation &&operation) const noexcept(traverse_is_noexcept< Operation, typename Aleph::concepts_detail::traverse_carg< Array_Container< T >, Operation >::type, const_source_t< Operation > >())
 Overload of traverse(Operation &) const that accepts rvalues.
 
bool traverse (Operation &&operation) noexcept(traverse_is_noexcept< Operation, typename Aleph::concepts_detail::traverse_arg< Array_Container< T >, Operation >::type, Array_Container< T > & >())
 Overload of traverse(Operation &) that accepts rvalues.
 
- Public Member Functions inherited from LocateFunctions< Array_Container< 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< Array_Container< 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< Array_Container< 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< Array_Container< 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< Array_Container< 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< Array_Container< 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< Array_Container< 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< Array_Container< 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< Array_Container< 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< Array_Container< 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< Array_Container< T > >
bool equal_to (const Array_Container< T > &r) const
 Equality test between this and r.
 
- Public Member Functions inherited from StlAlephIterator< Array_Container< T > >
iterator begin () noexcept
 Return an STL-compatible iterator to the first element.
 
const_iterator begin () const noexcept
 Return a const iterator to the first element.
 
iterator end () noexcept
 Return an STL-compatible end iterator.
 
const_iterator end () const noexcept
 Return a const end iterator.
 
const_iterator cbegin () const noexcept
 Return a const iterator to the first element.
 
const_iterator cend () const noexcept
 Return a const end iterator.
 

Private Attributes

T * base = nullptr
 
size_t n = 0
 

Additional Inherited Members

- Static Public Member Functions inherited from FunctionalMethods< Array_Container< T >, T >
static Array_Container< 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< Array_Container< T >, T >
 and
 Insert a new element into the container by constructing it from the given args.
 
and Aleph::InvocableWith< Operation &, const T & > and
 Conditional mapping of the elements of the container.
 

Detailed Description

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

Lightweight wrapper that provides Aleph-w container interface for raw arrays.

This class wraps a raw C array pointer and size, providing:

  • Size and capacity queries
  • First/last element access
  • Iterator access
  • Compatibility with Aleph-w functional methods (map, filter, fold, etc.)

The container does not own the array - it is a non-owning view.

Note
Constness is shallow, as in std::span: a const Array_Container<T> still gives mutable access to the elements through get_first(), get_last(), get_base() and its iterators. For read-only access use Array_Container<const T>.
Template Parameters
TElement type.

Definition at line 419 of file array_it.H.

Member Typedef Documentation

◆ Item_Type

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

The type of elements in the container.

Definition at line 431 of file array_it.H.

Constructor & Destructor Documentation

◆ Array_Container()

template<typename T >
Aleph::Array_Container< T >::Array_Container ( T *  base_ptr,
const size_t  d 
)
inline

Construct a container wrapping a raw array.

Parameters
base_ptrPointer to the array.
dSize of the array.

Definition at line 446 of file array_it.H.

Member Function Documentation

◆ capacity()

template<typename T >
constexpr size_t Aleph::Array_Container< T >::capacity ( ) const
inlineconstexprnoexcept

Get the capacity.

Returns
Same as size() for this container.

Definition at line 470 of file array_it.H.

References Aleph::Array_Container< T >::n.

◆ get_base()

template<typename T >
T * Aleph::Array_Container< T >::get_base ( ) const
inlinenoexcept

Get the base pointer.

Returns
Pointer to the underlying array.

Definition at line 436 of file array_it.H.

References Aleph::Array_Container< T >::base.

Referenced by TEST().

◆ get_first()

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

Get the first element.

Returns
Reference to the first element.
Exceptions
std::underflow_errorif empty.

Definition at line 479 of file array_it.H.

References ah_underflow_error_if, Aleph::Array_Container< T >::base, and Aleph::Array_Container< T >::n.

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

◆ get_it()

template<typename T >
Iterator Aleph::Array_Container< T >::get_it ( ) const
inline

Get an iterator to the beginning.

Returns
Iterator positioned at the first element.

Definition at line 505 of file array_it.H.

Referenced by TEST(), and TEST_F().

◆ get_last()

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

Get the last element.

Returns
Reference to the last element.
Exceptions
std::underflow_errorif empty.

Definition at line 489 of file array_it.H.

References ah_underflow_error_if, Aleph::Array_Container< T >::base, and Aleph::Array_Container< T >::n.

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

◆ is_empty()

template<typename T >
constexpr bool Aleph::Array_Container< T >::is_empty ( ) const
inlineconstexprnoexcept

Check if the container is empty.

Returns
true if size is 0.

Definition at line 454 of file array_it.H.

References Aleph::Array_Container< T >::n.

Referenced by TEST(), and TEST().

◆ size()

template<typename T >
constexpr size_t Aleph::Array_Container< T >::size ( ) const
inlineconstexprnoexcept

Get the number of elements.

Returns
Number of elements.

Definition at line 462 of file array_it.H.

References Aleph::Array_Container< T >::n.

Referenced by TEST(), and TEST().

Member Data Documentation

◆ base

template<typename T >
T* Aleph::Array_Container< T >::base = nullptr
private

◆ n


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