Aleph-w 3.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

Tget_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.
 
Tget_first () const
 Get the first element.
 
Tget_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 >())
 Traverse the container via its iterator and performs a conditioned operation on each item.
 
bool traverse (Operation &operation) const noexcept(traverse_is_noexcept< Operation >())
 Const overload of traverse(Operation&).
 
bool traverse (Operation &&operation) const noexcept(traverse_is_noexcept< Operation >())
 Overload of traverse(Operation&) const that accepts rvalues.
 
bool traverse (Operation &&operation) noexcept(traverse_is_noexcept< Operation >())
 Overload of traverse(Operation&) that accepts rvalues.
 
- Public Member Functions inherited from LocateFunctions< Array_Container< T >, T >
auto get_it () const
 Return a properly initialized iterator positioned at the first item on the container.
 
auto get_it (const size_t pos) const
 Return a properly initialized iterator positioned at the pos item on the container.
 
auto get_itor () const
 Alias of get_it().
 
T & nth_ne (const size_t n) noexcept
 Return the n‑th element without bounds checking.
 
const T & nth_ne (const size_t n) const noexcept
 Const overload of nth_ne(size_t).
 
T & nth (const size_t n)
 Return the n-th item of container.
 
const T & nth (const size_t n) const
 Const overload of nth(size_t).
 
T * find_ptr (Operation &operation) noexcept(operation_is_noexcept< Operation >())
 Find a pointer to an item in the container according to a searching criteria.
 
const T * find_ptr (Operation &operation) const noexcept(operation_is_noexcept< Operation >())
 Const overload of find_ptr(Operation&).
 
const T * find_ptr (Operation &&operation) const noexcept(operation_is_noexcept< Operation >())
 Overload of find_ptr(Operation&) const that accepts rvalues.
 
T * find_ptr (Operation &&operation) noexcept(operation_is_noexcept< Operation >())
 Overload of find_ptr(Operation&) that accepts rvalues.
 
size_t find_index (Operation &operation) const noexcept(operation_is_noexcept< Operation >())
 Find the position of an item in the container according to a searching criteria.
 
size_t find_index (Operation &&operation) const noexcept(operation_is_noexcept< Operation >())
 Overload of find_index(Operation&) that accepts rvalues.
 
std::tuple< bool, T > find_item (Operation &operation) noexcept(operation_is_noexcept< Operation >())
 Safe sequential searching of an item matching a criteria.
 
std::tuple< bool, T > find_item (Operation &operation) const noexcept(operation_is_noexcept< Operation >())
 
std::tuple< bool, T > find_item (Operation &&operation) noexcept(operation_is_noexcept< Operation >())
 
std::tuple< bool, T > find_item (Operation &&operation) const noexcept(operation_is_noexcept< Operation >())
 
- Public Member Functions inherited from FunctionalMethods< Array_Container< T >, T >
void emplace (Args &&... args)
 Appends a new element into the container by constructing it in-place with the given args.
 
void emplace_end (Args &&... args)
 
void emplace_ins (Args &&... args)
 Insert a new element into the container by constructing it in-place with the given args.
 
size_t ninsert (Args ... args)
 Insert n variadic items.
 
size_t nappend (Args ... args)
 Append n variadic items.
 
void for_each (Operation &operation)
 Traverse all the container and performs an operation on each element.
 
void for_each (Operation &operation) const
 Const overload of for_each(Operation&).
 
void for_each (Operation &&operation) const
 Overload of for_each(Operation&) const that accepts rvalues.
 
void for_each (Operation &&operation)
 Overload of for_each(Operation&) that accepts rvalues.
 
void each (Operation &operation)
 Alias of for_each(Operation&).
 
void each (Operation &operation) const
 Const alias of for_each(Operation&).
 
void each (Operation &&operation) const
 Const alias of for_each(Operation&) that accepts rvalues.
 
void each (Operation &&operation)
 Alias of for_each(Operation&) that accepts rvalues.
 
void each (size_t pos, const size_t slice, Operation &operation) const
 Traverse the container starting at pos taking one item every slice, performing a mutable operation on each visited element.
 
void each (const size_t pos, const size_t slice, Operation &&operation) const
 
void mutable_for_each (Operation &operation)
 
void mutable_for_each (Operation &&operation)
 
bool all (Operation &operation) const
 Check if all the elements of container satisfy a condition.
 
bool all (Operation &&operation) const
 Overload of all(Operation&) that accepts rvalues.
 
bool exists (Operation &op) const
 Test for existence in the container of an element satisfying a criteria.
 
bool exists (Operation &&op) const
 Overload of exists(Operation&) that accepts rvalues.
 
Aleph::DynList< __T > maps (Operation &op) const
 Map the elements of the container.
 
Aleph::DynList< __T > maps (Operation &&op) const
 Overload of maps(Operation&) that accepts rvalues.
 
Aleph::DynList< __Tmaps_if (Prop prop, Operation &op) const
 Conditional mapping of the elements of the container.
 
Aleph::DynList< __Tmaps_if (Prop prop, Operation &&op) const
 Overload of maps_if(Prop, Operation&) that accepts rvalues.
 
Aleph::DynList< T > to_dynlist () const
 Convert container to DynList.
 
std::vector< T > to_vector () const
 Convert container to std::vector.
 
__T foldl (const __T &init, Op &op) const
 Fold the elements of the container to a specific result.
 
__T foldl (const __T &init, Op &&op=Op()) const
 Overload of foldl(const __T&, Op&) that accepts rvalues.
 
__T fold_left (const __T &init, Op &op) const
 Alias for foldl with the same accumulator type.
 
__T fold_left (const __T &init, Op &&op=Op()) const
 Overload of fold_left(const __T&, Op&) that accepts rvalues.
 
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.
 
fold (const T &init, Operation &&operation) const
 Overload of fold(const T&, Operation&) that accepts rvalues.
 
Aleph::DynList< T > filter (Operation &operation) const
 Filter the elements of a container according to a matching criteria.
 
Aleph::DynList< T > filter (Operation &&operation) const
 Overload of filter(Operation&) that accepts rvalues.
 
Aleph::DynList< const T * > ptr_filter (Operation &operation) const
 Filter the elements of a container according to a matching criteria and return a pointer to the matched items in the container.
 
Aleph::DynList< const T * > ptr_filter (Operation &&operation) const
 Overload of ptr_filter(Operation&) that accepts rvalues.
 
Aleph::DynList< std::tuple< T, size_t > > pfilter (Operation &operation) const
 Filter the elements of a container according to a matching criteria and determine its positions respect to the traversal of container.
 
Aleph::DynList< std::tuple< T, size_t > > pfilter (Operation &&operation) const
 Overload of pfilter(Operation&) that accepts rvalues.
 
std::pair< Aleph::DynList< T >, Aleph::DynList< T > > partition (Operation &op) const
 Exclusive partition of container according to a filter criteria.
 
std::pair< Aleph::DynList< T >, Aleph::DynList< T > > partition (Operation &&op) const
 Overload of partition(Operation&) 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 criteria.
 
std::tuple< Aleph::DynList< T >, Aleph::DynList< T > > tpartition (Operation &&op) const
 Overload of tpartition(Operation&) that accepts rvalues.
 
size_t length () const noexcept
 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 elements seen in the container between i and j position respect to its traversal.
 
Aleph::DynList< T > drop (const size_t n) const
 Drop the first n elements seen in the container during its traversal.
 
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
 
- Public Member Functions inherited from EqualToMethod< Array_Container< T > >
bool equal_to (const Array_Container< T > &r) const noexcept
 Test if elements of this are exactly contained in another container.
 
bool operator== (const Array_Container< T > &r) const noexcept
 
bool operator!= (const Array_Container< T > &r) const noexcept
 Negation of equal_to()
 
- 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

Tbase = nullptr
 
const size_t n = 0
 

Additional Inherited Members

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.

Template Parameters
TElement type.

Definition at line 366 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 380 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 392 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 410 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 385 of file array_it.H.

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

◆ 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 416 of file array_it.H.

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

Referenced by 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 444 of file array_it.H.

Referenced by 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 427 of file array_it.H.

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

Referenced by 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 400 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 405 of file array_it.H.

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

Referenced by TEST(), and TEST().

Member Data Documentation

◆ base

◆ n


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