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

#include <tpl_dynArray.H>

Inherits LocateFunctions< DynArray< T >, T >, FunctionalMethods< DynArray< T >, T >, GenericItems< Container, T >, EqualSequenceMethod< DynArray< T > >, and StlAlephIterator< DynArray< T > >.

Inherited by Aleph::DynArray_Set< T, Equal >.

Collaboration diagram for Aleph::DynArray< T >:
[legend]

Classes

class  Iterator
 Iterator on the items of array. More...
 
class  Proxy
 

Public Types

using Item_Type = T
 
using Key_Type = T
 The type of element stored in the array.
 
using Const_Iterator = Aleph::Const_Iterator< Iterator >
 Read-only iterator: the iterator of a constant array; it never allocates.
 
- Public Types inherited from StlAlephIterator< DynArray< T > >
using iterator = StlIterator< DynArray< T > >
 
using const_iterator = StlConstIterator< DynArray< T > >
 

Public Member Functions

size_t get_dir_size () const noexcept
 Return the directory size.
 
size_t get_seg_size () const noexcept
 Return the segment size.
 
size_t get_block_size () const noexcept
 Return the block size.
 
size_t size () const noexcept
 Return the current dimension of array.
 
size_t max_size () const noexcept
 Return the maximum allowed dimension (or the maximum number of elements that could have the array treated as a container).
 
size_t get_num_blocks () const noexcept
 Return the number of blocks consumed by the array.
 
void set_default_initial_value (const T &value) noexcept(std::is_nothrow_copy_assignable_v< T >)
 Set the default value.
 
void set_default_initial_value (T &&value=T()) noexcept(std::is_nothrow_swappable_v< T >)
 See set_default_initial_value(const T & value).
 
 DynArray (const size_t _pow_dir, const size_t _pow_seg, const size_t _pow_block)
 Construct a dynamic array given directory, segment and block sizes.
 
 DynArray ()
 Construct an empty array with the default geometry.
 
 DynArray (const size_t dim)
 Construct an array of logical size dim without allocating entries.
 
 DynArray (const size_t n, const T &value)
 Construct an array of n copies of value; every entry is allocated.
 
template<template< typename > class List>
 DynArray (const List< T > &l)
 
template<class It >
requires (not std::is_arithmetic_v<It> and requires (It it) { *it; ++it; it != it; })
 DynArray (It b, It e)
 
 DynArray (std::initializer_list< T > l)
 
 ~DynArray ()
 
void copy_array (const DynArray< T > &src_array)
 Copy the items of src_array to this
 
 DynArray (const DynArray< T > &array)
 Copy constructor: build an exact copy of array.
 
DynArray< T > & operator= (const DynArray< T > &array)
 Copy assignment: *this becomes an exact copy of array.
 
void swap (DynArray< T > &array) noexcept(std::is_nothrow_swappable_v< T >)
 Swap in constant time array with this
 
 DynArray (DynArray &&other) noexcept(std::is_nothrow_default_constructible_v< T > and std::is_nothrow_swappable_v< T >)
 Move constructor; allocates nothing.
 
DynArray & operator= (DynArray &&other) noexcept(std::is_nothrow_swappable_v< T >)
 Move assignment: swap the contents with other.
 
T & access (const size_t i) noexcept
 Fast access without checking allocation and bound_min_clock checking.
 
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) noexcept
 See access(const size_t i).
 
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.
 
bool exist (const size_t i) const
 Return true if the i-th entry is accessible.
 
T * test (const size_t i) const noexcept
 Test if the i-th entry es writable,.
 
T & touch (const size_t i)
 Touch the entry i.
 
void reserve (const size_t l, const size_t r)
 Allocate a range of entries.
 
void reserve (const size_t dim)
 Allocate the first dim entries and make size() at least dim.
 
void cut_ne (const size_t new_dim=0)
 
void cut (const size_t new_dim=0)
 Cut the array to a new dimension; that is, it reduces the dimension of array and frees the remaining memory.
 
void adjust (const size_t dim)
 Set a new dimension.
 
void empty () noexcept
 Empty the array.
 
void clear () noexcept
 Empties the container.
 
const T & read (const size_t i) const
 Read entry i without allocating memory.
 
const T & operator[] (const size_t i) const
 Read entry i of a constant array; equivalent to read(i).
 
Proxy operator[] (const size_t i)
 Access entry i of a modifiable array through a proxy.
 
T & nth (const size_t n)
 Return a modifiable reference to entry n.
 
const T & nth (const size_t n) const
 Return entry n of a constant array; equivalent to read(n).
 
T & nth_ne (const size_t n)
 Return a modifiable reference to entry n without checking n.
 
const T & nth_ne (const size_t n) const noexcept
 Return entry n of a constant array without checking n.
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, T &>
T * find_ptr (Operation &operation)
 Return a pointer to the first entry satisfying a criterion.
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const T &>
const T * find_ptr (Operation &operation) const
 Constant overload of find_ptr(); it never allocates memory.
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, T &>
T * find_ptr (Operation &&operation)
 See find_ptr(Operation & operation).
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const T &>
const T * find_ptr (Operation &&operation) const
 See find_ptr(Operation & operation) const.
 
T & append ()
 Allocate a new entry to the end of array.
 
T & append (const T &data)
 Copy data to the end of array, increase the dimension and return a modifiable reference to the copied data.
 
T & append (T &&data)
 Move data to the end of array, increase the dimension and return a modifiable reference to the copied data.
 
T & insert (const T &item)
 Insert a copy of item at the beginning of the array.
 
T & insert (T &&item)
 Move item to the beginning of the array.
 
void push (const T &data)
 See append(const T & data).
 
T & push (T &&data)
 See append(T && data).
 
void put (const T &data)
 See append(const T & data).
 
T & put (T &&data)
 See append(T && data).
 
void remove (T &item)
 Given a valid reference to an item in the array, it removes it and decrease the dimension.
 
void erase (T &item)
 See remove(T & item).
 
bool is_empty () const noexcept
 Return true if the array is empty.
 
Array< T > to_array () const
 Copy contents into Aleph::Array (requires copyable elements).
 
DynArray & reverse ()
 Reverse the order of items in an array.
 
T pop ()
 Remove the last item of array (as if this was a stack)
 
T & top ()
 Return a modifiable reference to the last item of stack.
 
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, it never allocates.
 
T & get_first ()
 Return a modifiable reference to the first item of array (as if this was a queue)
 
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, it never allocates.
 
T & get_last ()
 Return a modifiable reference to the last item of array (as if this was a queue)
 
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, it never allocates.
 
Iterator get_it ()
 Iterator on the modifiable array, positioned on entry 0.
 
Const_Iterator get_it () const
 Iterator on the constant array, positioned on entry 0.
 
Iterator get_it (const size_t pos)
 Iterator on the modifiable array, positioned on entry pos.
 
Const_Iterator get_it (const size_t pos) const
 Iterator on the constant array, positioned on entry pos.
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, const T &>
bool traverse (Operation &operation) const noexcept(Aleph::NothrowPredicateWith< Operation &, const T & >)
 Traverse a constant array and execute a conditioned operation, which must have the signature:
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, T &>
bool traverse (Operation &operation)
 Traverse a modifiable array; operation receives modifiable references, with the signature bool operation(T & item).
 
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)
 See traverse(Operation & operation).
 
template<class Operation >
requires Aleph::InvocableWith<Operation &, const T &>
void each (Operation &operation) const
 Alias of for_each(); see FunctionalMethods::for_each().
 
template<class Operation >
requires Aleph::InvocableWith<Operation &, const T &>
void each (Operation &&operation) const
 See each(Operation & operation) const.
 
template<class Operation >
requires Aleph::InvocableWith<Operation &, const T &>
void each (const size_t pos, const size_t slice, Operation &operation) const
 Visit the entries at positions pos, pos + slice, ... of a constant array; see FunctionalMethods::each().
 
template<class Operation >
requires Aleph::InvocableWith<Operation &, const T &>
void each (const size_t pos, const size_t slice, Operation &&operation) const
 See each(size_t pos, size_t slice, Operation & operation) const.
 
template<class Operation >
requires Aleph::InvocableWith<Operation &, T &>
void each (const size_t pos, const size_t slice, Operation &operation)
 Visit, and possibly modify, the entries at positions pos, pos + slice, pos + 2 slice, ... of a modifiable array.
 
template<class Operation >
requires Aleph::InvocableWith<Operation &, T &>
void each (const size_t pos, const size_t slice, Operation &&operation)
 See each(size_t pos, size_t slice, Operation & operation).
 
- Public Member Functions inherited from LocateFunctions< DynArray< 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< DynArray< 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< DynArray< 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< DynArray< 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< DynArray< 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< DynArray< 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< DynArray< 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< DynArray< 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< DynArray< 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< DynArray< 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< DynArray< T > >
bool equal_to (const DynArray< T > &r) const
 Equality test between this and r.
 
- Public Member Functions inherited from StlAlephIterator< DynArray< 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 Public Member Functions

static void compute_sizes (const size_t n, size_t &d, size_t &s, size_t &b)
 Given a dimension n, it proposes values for the directory, segment and block sizes.
 
static std::tuple< size_t, size_t, size_t > compute_sizes (const size_t n)
 Given a dimension n, it proposes values for the directory, segment and block sizes.
 
- Static Public Member Functions inherited from FunctionalMethods< DynArray< T >, T >
static DynArray< 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.
 

Static Public Attributes

static const size_t Default_Pow_Dir = 6
 The type of element stored in the array.
 
static const size_t Default_Pow_Seg = 8
 Default two power for directory size.
 
static const size_t Default_Pow_Block = 12
 Default two power for segment size.
 
static const unsigned long long Max_Dim_Allowed = 256 * 1024 * 1024 * 1024ull
 Maximum dimension allowed.
 

Private Member Functions

size_t index_in_dir (const size_t i) const noexcept
 
size_t modulus_from_index_in_dir (const size_t i) const noexcept
 
size_t index_in_seg (const size_t &i) const noexcept
 
size_t index_in_block (const size_t i) const noexcept
 
void fill_dir_to_null () noexcept
 
void fill_seg_to_null (T **seg) noexcept
 
void allocate_dir ()
 
void ensure_dir ()
 Allocate the directory if the array has none.
 
void resize_dir (const size_t i)
 
void allocate_segment (T **&seg)
 
void allocate_block (T *&block)
 Allocate a block filled with the default value.
 
void release_segment (T **&seg) noexcept
 
void release_block (T *&block) noexcept
 
void release_blocks_and_segment (T **&seg) noexcept
 
void ensure_not_empty (const char *context) const
 
void release_all_segments_and_blocks () noexcept
 
void release_dir () noexcept
 
size_t divide_by_block_size (const size_t number) const noexcept
 
size_t modulus_by_block_size (const size_t number) const noexcept
 
void allocate_block (T *&block, T *src_block)
 
void allocate_segment (T **&seg, T **src_seg)
 
template<class Operation >
size_t index_of_first (Operation &operation) const
 
template<class Operation >
bool const_traverse (Operation &operation) const noexcept(Aleph::NothrowPredicateWith< Operation &, const T & >)
 
template<class Operation >
bool mutable_traverse (Operation &operation)
 

Static Private Member Functions

static size_t two_raised (const size_t n)
 Return 2^n.
 
static size_t compute_dim (size_t d, size_t s, size_t b)
 Return the number of entries of a d/s/b geometry.
 
static size_t next2Pow (const size_t number) noexcept
 

Private Attributes

size_t pow_dir = Default_Pow_Dir
 
size_t pow_seg = Default_Pow_Seg
 
size_t pow_block = std::min(Default_Pow_Block, Max_Pow_Block)
 
size_t seg_plus_block_pow = pow_seg + pow_block
 
size_t mask_seg_plus_block = two_raised(seg_plus_block_pow) - 1
 
size_t dir_size = two_raised(pow_dir)
 
size_t seg_size = two_raised(pow_seg)
 
size_t block_size = two_raised(pow_block)
 
unsigned long long max_dim = two_raised(seg_plus_block_pow + pow_dir)
 
size_t mask_seg = seg_size - 1
 
size_t mask_block = block_size - 1
 
size_t current_dim
 
size_t num_segs = 0
 
size_t num_blocks = 0
 
T *** dir = nullptr
 
T default_initial_value = T()
 
T * default_initial_value_ptr = &default_initial_value
 

Static Private Attributes

static const size_t Max_Bits_Allowed = 8 * sizeof(size_t)
 Default two power for block size.
 
static const size_t Max_Pow_Block = (Max_Bits_Allowed - Default_Pow_Dir - Default_Pow_Seg - 1)
 

Additional Inherited Members

- Public Attributes inherited from FunctionalMethods< DynArray< 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::DynArray< T >

Lazy and scalable dynamic array

This class implements a very versatile dynamic array which would represent a good trade-off between fast and constant access time and memory consumption. The array is lazy in the sense that the dimension grows dynamically and the required memory for a cell could be allocated at the first writing.

The data structure consists of three array types. A first array type is called block, and it is a contiguous chunk of block_size data entries. if an array occupies n entries then there are n/block_size + 1 blocks allocated. The blocks are indexed by segments of seg_size blocks which in turn are indexed by a directory of dir_size segment. For accessing to entry i the following calculations are done:

  1. The directory entry corresponds to i/(seg_size*block_size).
  2. The modulus of previous operation is divided between block_size. This gives the index in the segment.
  3. Finally, the modulus of previous operation gives the index of i-th in the block.

So, there are always four operations for each access what gives a constant access time.

In order to faster perform the calculations, the directory, segment and block size are adjusted to two powers. In this way, the division and modulus can be done with shifting and masking.

Access through [] operator

For lazy writing, that is to allocate the block just when it is certain that this will be used, the operator [] is used. A read of an entry whose block was never allocated, through read(i) or [] on a constant array, some such as:

std::cout << a.read(i) << endl;

returns the default initialization value without allocating anything. This value is the result of the default constructor call, unless set_default_initial_value() changed it. On a modifiable array, a[i] returns a proxy that cannot tell a read from a write, so using it as a value allocates the block (it then holds the default value). Traversals and iterators of a constant array never allocate; on a modifiable array they hand out modifiable references, so they allocate the blocks they visit. Use std::as_const(a) to traverse or iterate without allocating.

At the contrary, if the first time that a writing is done, some such as:

a[i] = value;

Then the block, and eventually the segment will be allocated. So is the directory, by the first write of the array: an array that was built and never written holds no memory, as one that was moved from.

Eventually the array could be fragmented and to consume memory some proportional to the writes done. Suppose for example that you only perform:

a[0] = value;
a[100000000] = value;

In this case, the registered dimension of array will be 100000000, but only two blocks will be allocated. If you only performs reads between \((0, 100000000)\) with read(), on a constant array or by traversing a constant array (for instance std::as_const(a)), always it will be returned the default value and neither a segment nor a block will be allocated, since they have not been written. Traversing the modifiable array instead allocates every block it visits.

Access through [] operator perform bound_min_clock checks and it requires to test if the segment and/or block have been allocated and eventually to allocate them.

Faster access though [] operator

If you know (you are absolutely sure of) that the entry has already been written, and consequently it has already its block allocated, then you could use the operator () for direct access.

Access with () operator does not perform any check (bounds and blocks and segment existence). This way is faster but unsure.

() operator is an alias of access(i) method.

In order to assure that a range of entries is already allocated, you could use reserve(l, r) method, which test and eventually allocates the needed memory for the entries comprised in the range \([l,r]\).

Managing a dynamic array as a list

From a functional perspective, an dynamic array could be treated as a list.

Initially, the array is empty.

A new item can be inserted with append(item. This method copy (or moves) the item to the next available entry (at the end). The dimension is increased in one unit.

You can also to treat the dynamic array as stack or queue.

Setting the directory, segment and block sizes

The interface offer a default constructor which normally sets the sizes and serves for almost all situations.

However, sometimes is desirable to set oneself these parameter. The principal justification is given for situations where the memory is very limited.

Note that a memory manager could have enough memory dispersed through the total of available chunks, but it could not exist a contiguous block of a given size. The more large is the block size, the higher is the probability for failing to allocate. So, there are circumstances where you could be interested in setting a small block size, to facilitate the block's allocation.

Of course, these settings restrict the maximum dimension, which eventually could be composed with a larger directory. As example, consider a directory of 1024 segments of 512 blocks of 4096 entries. This gives a total of

\(1024 \times 512 \times 4096 = 2147483648\) entries.

Now suppose that you think that 4096 is too much for a block, then you could set the block to 128 and displace the difference to the directory. This gives sizes of 32768, 512 and 128 respectively and thus to obtain the same maximum capacity.

You could think that failure probability is displaced to the directory allocation, but the directory is allocated once at construction time.

Note
Due to the directory, segment, and block structuring, not all entries in the array are contiguous in memory. Only the entries within the same block are contiguous.

Definition at line 215 of file tpl_dynArray.H.

Member Typedef Documentation

◆ Const_Iterator

Read-only iterator: the iterator of a constant array; it never allocates.

Definition at line 2033 of file tpl_dynArray.H.

◆ Item_Type

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

Definition at line 223 of file tpl_dynArray.H.

◆ Key_Type

template<typename T >
using Aleph::DynArray< T >::Key_Type = T

The type of element stored in the array.

Definition at line 224 of file tpl_dynArray.H.

Constructor & Destructor Documentation

◆ DynArray() [1/9]

template<typename T >
Aleph::DynArray< T >::DynArray ( const size_t  _pow_dir,
const size_t  _pow_seg,
const size_t  _pow_block 
)
inline

Construct a dynamic array given directory, segment and block sizes.

It allocates no directory: the first write does. It builds the default value, an item built by default.

Parameters
[in]_pow_dirtwo power for directory size
[in]_pow_segtwo power for segment size
[in]_pow_blocktwo power for block size
Exceptions
length_errorif the given sizes exceed the maximum possible dimension
overflow_errorif it happens an arithmetic overflow with the bits operations
Anyexception from the default constructor of T, which builds the default value.

Definition at line 800 of file tpl_dynArray.H.

References ah_length_error_if, Aleph::DynArray< T >::max_dim, and Aleph::DynArray< T >::Max_Dim_Allowed.

◆ DynArray() [2/9]

template<typename T >
Aleph::DynArray< T >::DynArray ( )
inline

Construct an empty array with the default geometry.

It allocates no directory: the first write does. It builds the default value, an item built by default.

Exceptions
Anyexception from the default constructor of T, which builds the default value.
Note
Not explicit, so DynArray<T> a = {}; and omitted aggregate members still work.

Definition at line 827 of file tpl_dynArray.H.

◆ DynArray() [3/9]

template<typename T >
Aleph::DynArray< T >::DynArray ( const size_t  dim)
inlineexplicit

Construct an array of logical size dim without allocating entries.

Segments and blocks are allocated lazily, on the first write that falls in them, and the directory, on the first write of the array: this constructor allocates none of them. The size of the directory covers the whole logical size from the start, so size() <= max_size(). Like std::vector<T>(dim), append() then writes at index dim. Entries that were never written have no storage; check them with exist() or test() before reading them with access().

The constructor is explicit: an integer never becomes a DynArray implicitly, so DynArray<T> a = n; and passing an integer where a DynArray is expected do not compile.

Parameters
[in]diminitial logical size; zero builds an empty array.
Exceptions
length_errorif dim is greater than Max_Dim_Allowed.
overflow_errorif it happens an arithmetic overflow with the bits operations
Anyexception from the default constructor of T, which builds the default value.

Definition at line 852 of file tpl_dynArray.H.

References ah_length_error_if, Aleph::DynArray< T >::compute_dim(), dim(), Aleph::DynArray< T >::dir_size, Aleph::DynArray< T >::max_dim, Aleph::DynArray< T >::Max_Dim_Allowed, Aleph::DynArray< T >::pow_block, Aleph::DynArray< T >::pow_dir, Aleph::DynArray< T >::pow_seg, and Aleph::DynArray< T >::two_raised().

◆ DynArray() [4/9]

template<typename T >
Aleph::DynArray< T >::DynArray ( const size_t  n,
const T &  value 
)
inline

Construct an array of n copies of value; every entry is allocated.

Parameters
[in]nnumber of entries; size() is n.
[in]valuevalue copied into each entry.
Exceptions
bad_allocif there is no enough memory.
length_errorif n is greater than Max_Dim_Allowed.
Anyexception from copy-assigning T; nothing is leaked.
Note
O(n), like std::vector<T>(n, value).

Definition at line 885 of file tpl_dynArray.H.

References Aleph::DynArray< T >::access(), Aleph::DynArray< T >::reserve(), and value.

◆ DynArray() [5/9]

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

Definition at line 895 of file tpl_dynArray.H.

◆ DynArray() [6/9]

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

Definition at line 895 of file tpl_dynArray.H.

◆ DynArray() [7/9]

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

Definition at line 895 of file tpl_dynArray.H.

◆ ~DynArray()

template<typename T >
Aleph::DynArray< T >::~DynArray ( )
inline

Definition at line 897 of file tpl_dynArray.H.

References Aleph::DynArray< T >::release_dir().

◆ DynArray() [8/9]

template<typename T >
Aleph::DynArray< T >::DynArray ( const DynArray< T > &  array)
inline

Copy constructor: build an exact copy of array.

The copy has the geometry, logical size and default value of array and allocates exactly the blocks that array has allocated, so an entry that array never wrote is not written in the copy either.

Parameters
[in]arraysource of copy
Exceptions
bad_allocif there is no enough memory
Anyexception from copy-assigning T; nothing is leaked, since the delegated constructor has already completed.

Definition at line 924 of file tpl_dynArray.H.

References Aleph::DynArray< T >::allocate_dir(), Aleph::DynArray< T >::allocate_segment(), Aleph::DynArray< T >::current_dim, Aleph::DynArray< T >::default_initial_value, Aleph::DynArray< T >::dir, and Aleph::DynArray< T >::dir_size.

◆ DynArray() [9/9]

template<typename T >
Aleph::DynArray< T >::DynArray ( DynArray< T > &&  other)
inlinenoexcept

Move constructor; allocates nothing.

Parameters
[in,out]othersource; it is left empty and reusable, without a directory, which its first write allocates again.
Exceptions
anythingthat the default constructor of T or swapping two T throws.

Definition at line 1007 of file tpl_dynArray.H.

References Aleph::DynArray< T >::default_initial_value, Aleph::DynArray< T >::default_initial_value_ptr, and Aleph::DynArray< T >::swap().

Member Function Documentation

◆ access() [1/2]

template<typename T >
const T & Aleph::DynArray< T >::access ( const size_t  i) const
inlinenoexcept

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

Definition at line 1052 of file tpl_dynArray.H.

References Aleph::DynArray< T >::dir, Aleph::DynArray< T >::index_in_block(), Aleph::DynArray< T >::index_in_dir(), and Aleph::DynArray< T >::index_in_seg().

◆ access() [2/2]

template<typename T >
T & Aleph::DynArray< T >::access ( const size_t  i)
inlinenoexcept

Fast access without checking allocation and bound_min_clock checking.

The purpose of this method is to access the i-th entry in the fastest possible way. For that, no checks are done.

Parameters
[in]iindex of entry to be accessed
Precondition
The block of entry i exists (exist(i) is true), for instance because the entry was written or reserve() covered it. Use read() to read an entry that may never have been written.
See also
exist

Definition at line 1042 of file tpl_dynArray.H.

References Aleph::DynArray< T >::dir, Aleph::DynArray< T >::index_in_block(), Aleph::DynArray< T >::index_in_dir(), and Aleph::DynArray< T >::index_in_seg().

Referenced by Aleph::DynArray< T >::DynArray(), Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::Floyd_All_Shortest_Paths(), Aleph::IO_Graph< GT, Load_Node, Store_Node, Load_Arc, Store_Arc, NF, AF >::Loaded_Nodes::add(), Aleph::Compiler_Line_Frontend::analyze(), Aleph::analyze_dataflow_function(), Aleph::Compiler_Semantic_Analyzer::analyze_imports(), Aleph::Compiler_Typed_Semantic_Analyzer::analyze_stmt(), Aleph::Compiler_Module_Semantic_Environment_Detail::append_unique_name(), Aleph::Compiler_Type_Substitution::apply(), Aleph::Compiler_IR_Lowering::Module_Builder::bind(), Aleph::Interpreter_Runtime::call_hir_function(), Aleph::Compiler_Typed_Semantic_Analyzer::collect_binding_free_type_variables(), Aleph::Compiler_Typed_Semantic_Analyzer::collect_environment_free_type_variables(), Aleph::compiler_dump_bytecode_globals(), Aleph::compiler_dump_cfg_function(), Aleph::compiler_dump_dataflow_analysis(), Aleph::compiler_dump_ir_function(), Aleph::compiler_dump_ssa_function(), Aleph::compiler_link_module_surfaces(), Aleph::compiler_render_module_order(), Aleph::compiler_resolve_module_order(), Aleph::Compute_Cut_Nodes< GT, SA >::compute_blocks(), Aleph::Compiler_SSA_Detail::compute_dominance_info(), Aleph::Compiler_Dataflow_Detail::compute_predecessor_lists(), Aleph::Compiler_Dataflow_Detail::compute_reachability(), Aleph::Compiler_SSA_Detail::compute_reachable_blocks(), Aleph::Random_Graph< GT, Init_Node, Init_Arc >::connect(), Aleph::Random_Digraph< GT, Init_Node, Init_Arc >::connect(), Random_Network_Flow< Net >::connect_ranks(), Aleph::Matrix_Graph< GT, SA >::copy(), Aleph::DynArray< T >::copy_array(), Aleph::DynArray_Set< T, Equal >::count(), Random_Network_Flow< Net >::create_ranks(), Aleph::eliminate_dead_code(), Aleph::Compiler_C_Backend::Emitter::emit_instruction(), Aleph::Compiler_C_Backend::Emitter::emit_terminator(), Aleph::Compiler_Driver::execute_files(), Aleph::Compiler_Generic_Driver::execute_files(), Aleph::Compiler_Bytecode_VM::execute_host_call(), Aleph::Compiler_Driver::find_artifact(), Aleph::Compiler_Line_Frontend::find_artifact(), Aleph::Compiler_IR_Lowering::Module_Builder::find_function_id(), Aleph::Compiler_Driver::find_source_index(), Aleph::Compiler_Line_Frontend::find_source_index(), Aleph::Compiler_MVP_Frontend::find_source_index(), Aleph::Compiler_Line_Frontend::flatten_program_in_import_order(), Aleph::Compiler_Dataflow_Detail::format_slot_constants(), Aleph::Compiler_C_Backend::Emitter::function_descriptor_symbol(), Aleph::Compiler_C_Backend::Emitter::function_symbol(), Aleph::Compiler_Typed_Semantic_Analyzer::instantiate_type(), Aleph::Compiler_Bytecode_Detail::intern_constant(), Aleph::interpreter_values_equal(), Aleph::Random_Graph< GT, Init_Node, Init_Arc >::join_any_odd_nodes(), Aleph::Random_Digraph< GT, Init_Node, Init_Arc >::join_any_unbalanced_nodes(), Aleph::Random_Graph< GT, Init_Node, Init_Arc >::join_through_the_complement(), Aleph::kosaraju_connected_components(), Aleph::Compiler_Line_Frontend::load_sources(), Aleph::Compiler_MVP_Frontend::load_sources(), Aleph::Compiler_IR_Lowering::Module_Builder::lookup(), Aleph::Compiler_IR_Lowering::Module_Builder::lower_expr(), Aleph::Compiler_Bytecode_Lowering::lower_function(), Aleph::Compiler_IR_Lowering::Module_Builder::lower_function_body(), Aleph::Compiler_SSA_Lowering::lower_function_internal(), Aleph::Compiler_Line_Frontend::lower_hir(), Aleph::Compiler_Line_Frontend::lower_ir(), Aleph::Compiler_CFG_Lowering::lower_statement_sequence(), Aleph::Compiler_CFG_Lowering::lower_stmt(), main(), main(), Aleph::Compiler_Bytecode_VM::make_validation_error(), Aleph::Compiler_Dataflow_Detail::mark_value_used(), Aleph::Compiler_Driver::merge_modules_from_order(), Aleph::Compiler_MVP_Frontend::merge_modules_from_order(), Aleph::Compiler_SSA_Detail::normalize_ir_function(), Aleph::DynArray< T >::operator()(), Aleph::DynArray< T >::operator()(), Aleph::Matrix_Graph< GT, SA >::operator()(), Aleph::Matrix_Graph< GT, SA >::operator()(), Aleph::Ady_Mat< GT, __Entry_Type, SA >::operator()(), Aleph::Compiler_Line_Frontend::parse(), Aleph::Compiler_MVP_Frontend::parse(), Aleph::Compiler_Line_Frontend::parse_function_line(), Aleph::Compiler_Line_Frontend::parse_import_line(), Aleph::Compiler_Line_Frontend::parse_let_line(), Aleph::Compiler_Driver::parse_registered_sources(), Aleph::Compiler_SSA_Detail::predecessor_index(), Aleph::Compiler_Typed_Semantic_Analyzer::predeclare_function(), Aleph::Compiler_IR_Lowering::Module_Builder::preload_global_bindings(), Aleph::Compiler_Driver::prepare_inputs(), Aleph::Compiler_Bytecode_VM::push_frame(), Aleph::Compiler_Bytecode_VM::read_callee_and_arguments(), Aleph::matgraph_detail::read_matrix(), Aleph::Compiler_Driver::record_ast_artifacts(), Aleph::Compiler_MVP_Frontend::record_ast_artifacts(), Aleph::DynArray_Set< T, Equal >::remove_all(), Aleph::Compiler_SSA_Detail::rename_recursive(), Aleph::Compiler_Driver_Detail::render_messages(), Aleph::Compiler_Ast_Context::reset(), Aleph::Compiler_Driver::resolve_import_order(), Aleph::Compiler_Typed_Semantic_Analyzer::resolve_module_type_declaration(), Aleph::Compiler_Module_Resolver_Detail::resolve_visit(), Aleph::DynArray_Set< T, Equal >::search(), Aleph::Compiler_Dataflow_Bit_Set::set(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), Aleph::Compiler_Dataflow_Bit_Set::test(), TEST(), TEST(), TEST(), Aleph::validate_cfg_function(), Aleph::validate_dataflow_analysis(), Aleph::validate_dead_code_elimination(), Aleph::validate_ir_function(), Aleph::validate_ssa_function(), Aleph::Compiler_Dataflow_Detail::value_constant(), and Aleph::Xml_Graph< GT, Node_Reader, Arc_Reader, Node_Writer, Arc_Writer >::write_graph().

◆ adjust()

template<typename T >
void Aleph::DynArray< T >::adjust ( const size_t  dim)
inline

Set a new dimension.

If dimension is greater than the current, then more memory is allocated; otherwise the remaining memory is freed. In both cases, the current dimension is adjusted.

Parameters
[in]dimnew dimension value
Exceptions
bad_allocif there is no enough memory.
length_errorif dim is greater than Max_Dim_Allowed; the array is then as it was.

Definition at line 1417 of file tpl_dynArray.H.

References Aleph::DynArray< T >::current_dim, Aleph::DynArray< T >::cut(), dim(), and Aleph::DynArray< T >::reserve().

Referenced by TEST().

◆ allocate_block() [1/2]

template<typename T >
void Aleph::DynArray< T >::allocate_block ( T *&  block)
inlineprivate

Allocate a block filled with the default value.

The array takes the block, and counts it, once it is whole: if a copy of the default value throws, the block is released, and the array is as it was.

Parameters
[out]blockwhere the block goes: an entry of a segment, or the pointer of a caller that then writes that entry.
Exceptions
bad_allocif there is no memory for the block.
Anyexception from copy-assigning T; nothing is leaked.

Definition at line 457 of file tpl_dynArray.H.

References Aleph::DynArray< T >::block_size, Aleph::DynArray< T >::default_initial_value_ptr, StlAlephIterator< DynArray< T > >::end(), and Aleph::DynArray< T >::num_blocks.

Referenced by Aleph::DynArray< T >::allocate_block(), Aleph::DynArray< T >::allocate_segment(), Aleph::DynArray< T >::Proxy::operator->(), Aleph::DynArray< T >::Proxy::operator=(), Aleph::DynArray< T >::Proxy::operator=(), Aleph::DynArray< T >::reserve(), and Aleph::DynArray< T >::touch().

◆ allocate_block() [2/2]

template<typename T >
void Aleph::DynArray< T >::allocate_block ( T *&  block,
T *  src_block 
)
inlineprivate

◆ allocate_dir()

◆ allocate_segment() [1/2]

◆ allocate_segment() [2/2]

template<typename T >
void Aleph::DynArray< T >::allocate_segment ( T **&  seg,
T **  src_seg 
)
inlineprivate

◆ append() [1/3]

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

Allocate a new entry to the end of array.

Increase the dimension and return a modifiable reference to the last entry

Definition at line 1639 of file tpl_dynArray.H.

References Aleph::DynArray< T >::size(), and Aleph::DynArray< T >::touch().

Referenced by Aleph::Two_Sat< GT >::add_at_most_one(), Aleph::analyze_dataflow_function(), Aleph::Compiler_Typed_Semantic_Analyzer::analyze_expr(), Aleph::Compiler_Semantic_Analyzer::analyze_imports(), Aleph::Compiler_Typed_Semantic_Analyzer::analyze_stmt(), Aleph::DynArray< T >::append(), Aleph::DynArray< T >::append(), Aleph::Compiler_Driver_Detail::append_artifact(), Aleph::Compiler_Driver::append_error(), Aleph::Compiler_Generic_Driver::append_error(), Aleph::Compiler_Line_Frontend::append_error(), Aleph::Compiler_MVP_Frontend::append_error(), Aleph::Compiler_Generic_Driver::append_run_failure_if_needed(), Aleph::Compiler_Module_Semantic_Environment_Detail::append_unique_name(), Aleph::Compiler_Typed_Semantic_Analyzer::append_unique_type_id(), Aleph::Compiler_Driver::append_warning(), Aleph::Compiler_Type_Substitution::apply(), Aleph::array_to_DynArray(), Aleph::Gen_Mo_On_Tree_Node< T, Policy >::build(), Aleph::Compiler_Typed_Semantic_Analyzer::collect_environment_free_type_variables(), Aleph::Compiler_Generic_Driver::collect_frontend_state(), Aleph::compiler_link_module_surfaces(), Aleph::compiler_resolve_module_order(), Aleph::Compiler_SSA_Detail::compute_dominance_info(), Aleph::Source_Manager::compute_line_starts(), Aleph::Compiler_Dataflow_Detail::compute_predecessor_lists(), Aleph::Compiler_Dataflow_Detail::compute_reachability(), Aleph::Compiler_SSA_Detail::compute_reachable_blocks(), Aleph::Random_Graph< GT, Init_Node, Init_Arc >::connect(), demo_calculator(), demo_city_coordinates(), demo_convex_hull_cities(), demo_convex_hull_performance(), demo_department_codes(), demo_dynarray(), demo_encoding_decoding(), demo_hash_dispatcher(), demo_regions_menu(), demo_text_processor(), demo_variadic_dispatcher(), demo_vector_dynarray(), Aleph::deque_to_DynArray(), Aleph::dyndlist_to_DynArray(), Aleph::dynlist_to_DynArray(), Aleph::eliminate_dead_code(), Aleph::Compiler_C_Backend::emit_module(), Aleph::Compiler_Typed_Semantic_Analyzer::enter_scope(), Aleph::Compiler_IR_Lowering::Module_Builder::enter_scope(), Aleph::Interpreter_Runtime::evaluate_expr(), Aleph::Compiler_Driver::execute_files(), Aleph::Compiler_Generic_Driver::execute_files(), Aleph::Compiler_Bytecode_VM::execute_host_call(), Aleph::Compiler_Driver::execute_source(), Aleph::Compiler_Generic_Driver::execute_source(), Aleph::Compiler_C_Backend::Emitter::fail(), DataGenerator::few_unique(), Aleph::Diagnostic_Builder::help(), Aleph::init_to_DynArray(), Aleph::Compiler_C_Backend::Emitter::initialize_symbols(), Aleph::DynArray< T >::insert(), Aleph::DynArray_Set< T, Equal >::insert(), Aleph::DynArray< T >::insert(), Aleph::DynArray_Set< T, Equal >::insert(), Aleph::Compiler_Typed_Semantic_Analyzer::instantiate_type(), Aleph::Compiler_Bytecode_Detail::intern_constant(), Aleph::Random_Graph< GT, Init_Node, Init_Arc >::join_any_odd_nodes(), Aleph::Random_Digraph< GT, Init_Node, Init_Arc >::join_any_unbalanced_nodes(), Aleph::Random_Graph< GT, Init_Node, Init_Arc >::join_through_the_complement(), Aleph::Compiler_Type_Context::list_to_array(), LLVMFuzzerTestOneInput(), Aleph::Compiler_Line_Frontend::load_sources(), Aleph::Compiler_MVP_Frontend::load_sources(), Aleph::Compiler_IR_Lowering::Module_Builder::lower_expr(), Aleph::Compiler_Bytecode_Lowering::lower_function(), Aleph::Compiler_SSA_Lowering::lower_function_internal(), Aleph::Compiler_Line_Frontend::lower_ir(), Aleph::Compiler_CFG_Lowering::lower_stmt(), Aleph::Compiler_IR_Lowering::Module_Builder::lower_stmt(), main(), main(), Aleph::Compiler_Ast_Context::make(), Aleph::Compiler_Dataflow_Detail::make_constant_vector(), make_dynarray(), Aleph::Compiler_Driver_Detail::merge_report(), Aleph::Compiler_SSA_Detail::normalize_ir_function(), Aleph::Diagnostic_Builder::note(), Aleph::Compiler_MVP_Frontend::parse(), Aleph::Compiler_Driver::parse_registered_sources(), populate_dynarray(), Aleph::Compiler_Typed_Semantic_Analyzer::predeclare_function(), Aleph::Compiler_IR_Lowering::Module_Builder::predeclare_function(), Aleph::Compiler_Driver::prepare_inputs(), Aleph::DynArray< T >::push(), Aleph::DynArray< T >::push(), Aleph::DynArray< T >::put(), Aleph::DynArray< T >::put(), DataGenerator::random(), Aleph::Compiler_Bytecode_VM::read_callee_and_arguments(), Aleph::Xml_Graph< GT, Node_Reader, Arc_Reader, Node_Writer, Arc_Writer >::read_graph(), Aleph::Compiler_Driver::record_import_order_artifact(), Aleph::Compiler_SSA_Detail::rename_recursive(), Aleph::Compiler_Bytecode_Interpreter_Detail::reset_values(), Aleph::Compiler_Dataflow_Bit_Set::resize(), Aleph::Compiler_Driver::resolve_import_order(), Aleph::Compiler_Line_Frontend::resolve_import_order(), Aleph::Compiler_MVP_Frontend::resolve_import_order(), Aleph::Compiler_Typed_Semantic_Analyzer::resolve_module_type_declaration(), Aleph::Compiler_Typed_Semantic_Analyzer::resolve_type_annotation(), Aleph::Compiler_Module_Resolver_Detail::resolve_visit(), DataGenerator::sawtooth(), Aleph::Compiler_Typed_Semantic_Analyzer::seed_function_annotation_type_variables(), Aleph::set_to_DynArray(), Aleph::sethash_to_DynArray(), Aleph::settree_to_DynArray(), DataGenerator::sorted_asc(), DataGenerator::sorted_desc(), Aleph::Compiler_Line_Frontend::split_tokens(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), test(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), test_DynSet(), test_DynSetLinHash(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), Aleph::to_DynArray(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), Aleph::validate_bytecode_function(), Aleph::validate_bytecode_module(), Aleph::validate_cfg_function(), Aleph::validate_cfg_module(), Aleph::validate_dataflow_analysis(), Aleph::validate_dead_code_elimination(), Aleph::validate_ir_function(), Aleph::validate_ir_module(), Aleph::validate_ssa_function(), Aleph::validate_ssa_module(), Aleph::vector_to_DynArray(), Aleph::vector_to_DynArray(), and Aleph::Compiler_C_Backend::Emitter::warn().

◆ append() [2/3]

template<typename T >
T & Aleph::DynArray< T >::append ( const T &  data)
inline

Copy data to the end of array, increase the dimension and return a modifiable reference to the copied data.

Definition at line 1646 of file tpl_dynArray.H.

References Aleph::DynArray< T >::append().

◆ append() [3/3]

template<typename T >
T & Aleph::DynArray< T >::append ( T &&  data)
inline

Move data to the end of array, increase the dimension and return a modifiable reference to the copied data.

Definition at line 1655 of file tpl_dynArray.H.

References Aleph::DynArray< T >::append().

◆ clear()

◆ compute_dim()

template<typename T >
static size_t Aleph::DynArray< T >::compute_dim ( size_t  d,
size_t  s,
size_t  b 
)
inlinestaticprivate

Return the number of entries of a d/s/b geometry.

Parameters
[in]dPower of two of the directory size.
[in]sPower of two of the segment size.
[in]bPower of two of the block size.
Returns
2^d * 2^s * 2^b.
Exceptions
std::overflow_errorif a power does not fit in a size_t.

Definition at line 270 of file tpl_dynArray.H.

References Aleph::DynArray< T >::two_raised().

Referenced by Aleph::DynArray< T >::DynArray(), Aleph::DynArray< T >::compute_sizes(), and Aleph::DynArray< T >::resize_dir().

◆ compute_sizes() [1/2]

template<typename T >
static std::tuple< size_t, size_t, size_t > Aleph::DynArray< T >::compute_sizes ( const size_t  n)
inlinestatic

Given a dimension n, it proposes values for the directory, segment and block sizes.

Parameters
[in]nproposed dimension
Returns
a 3-tuple with the powers of two of the directory, segment and block sizes
Exceptions
overflow_errorif n is greater than 2^63

Definition at line 315 of file tpl_dynArray.H.

References Aleph::DynArray< T >::compute_sizes().

◆ compute_sizes() [2/2]

template<typename T >
static void Aleph::DynArray< T >::compute_sizes ( const size_t  n,
size_t &  d,
size_t &  s,
size_t &  b 
)
inlinestatic

Given a dimension n, it proposes values for the directory, segment and block sizes.

Parameters
[in]nproposed dimension
[out]dpower of two of the directory size
[out]spower of two of the segment size
[out]bpower of two of the block size
Exceptions
overflow_errorif n is greater than 2^63, so that no geometry of size_t entries can hold it

Definition at line 286 of file tpl_dynArray.H.

References Aleph::DynArray< T >::compute_dim(), Aleph::DynArray< T >::Default_Pow_Block, Aleph::DynArray< T >::Default_Pow_Dir, and Aleph::DynArray< T >::Default_Pow_Seg.

Referenced by Aleph::DynArray< T >::compute_sizes(), and Aleph::DynMatrix< T >::set_dimension().

◆ const_traverse()

template<typename T >
template<class Operation >
bool Aleph::DynArray< T >::const_traverse ( Operation &  operation) const
inlineprivatenoexcept

◆ copy_array()

template<typename T >
void Aleph::DynArray< T >::copy_array ( const DynArray< T > &  src_array)
inline

Copy the items of src_array to this

Parameters
[in]src_arraysource array

Definition at line 906 of file tpl_dynArray.H.

References Aleph::DynArray< T >::access(), Aleph::DynArray< T >::current_dim, and Aleph::DynArray< T >::exist().

◆ cut()

◆ cut_ne()

◆ divide_by_block_size()

template<typename T >
size_t Aleph::DynArray< T >::divide_by_block_size ( const size_t  number) const
inlineprivatenoexcept

◆ each() [1/6]

template<typename T >
template<class Operation >
requires Aleph::InvocableWith<Operation &, T &>
void Aleph::DynArray< T >::each ( const size_t  pos,
const size_t  slice,
Operation &&  operation 
)
inline

See each(size_t pos, size_t slice, Operation & operation).

Definition at line 2262 of file tpl_dynArray.H.

◆ each() [2/6]

template<typename T >
template<class Operation >
requires Aleph::InvocableWith<Operation &, const T &>
void Aleph::DynArray< T >::each ( const size_t  pos,
const size_t  slice,
Operation &&  operation 
) const
inline

See each(size_t pos, size_t slice, Operation & operation) const.

Definition at line 2226 of file tpl_dynArray.H.

References Aleph::DynArray< T >::each().

◆ each() [3/6]

template<typename T >
template<class Operation >
requires Aleph::InvocableWith<Operation &, T &>
void Aleph::DynArray< T >::each ( const size_t  pos,
const size_t  slice,
Operation &  operation 
)
inline

Visit, and possibly modify, the entries at positions pos, pos + slice, pos + 2 slice, ... of a modifiable array.

Unlike the generic FunctionalMethods::each(pos, slice, op), whose modifiable traversal would allocate every block of the array, only the blocks of the visited entries are allocated, as a[i] does.

Parameters
[in]posposition of the first visited entry.
[in]slicedistance between two consecutive visited entries; nothing is visited if it is zero.
[in]operationoperation with signature void(T &).
Exceptions
bad_allocif the block of a visited entry cannot be allocated, and anything that operation throws.

Definition at line 2247 of file tpl_dynArray.H.

References Aleph::DynArray< T >::current_dim, and Aleph::DynArray< T >::touch().

◆ each() [4/6]

template<typename T >
template<class Operation >
requires Aleph::InvocableWith<Operation &, const T &>
void Aleph::DynArray< T >::each ( const size_t  pos,
const size_t  slice,
Operation &  operation 
) const
inline

Visit the entries at positions pos, pos + slice, ... of a constant array; see FunctionalMethods::each().

It never allocates memory.

Parameters
[in]posposition of the first visited entry.
[in]slicedistance between two consecutive visited entries.
[in]operationoperation with signature void(const T &).
Exceptions
anythingthat operation throws.

Definition at line 2218 of file tpl_dynArray.H.

References Aleph::DynArray< T >::each().

◆ each() [5/6]

template<typename T >
template<class Operation >
requires Aleph::InvocableWith<Operation &, const T &>
void Aleph::DynArray< T >::each ( Operation &&  operation) const
inline

See each(Operation & operation) const.

Definition at line 2203 of file tpl_dynArray.H.

References FunctionalMethods< DynArray< T >, T >::for_each().

◆ each() [6/6]

template<typename T >
template<class Operation >
requires Aleph::InvocableWith<Operation &, const T &>
void Aleph::DynArray< T >::each ( Operation &  operation) const
inline

Alias of for_each(); see FunctionalMethods::for_each().

Parameters
[in]operationoperation with signature void(const T &).
Exceptions
anythingthat operation throws.

Definition at line 2195 of file tpl_dynArray.H.

References FunctionalMethods< DynArray< T >, T >::for_each().

Referenced by Aleph::DynArray< T >::each(), and Aleph::DynArray< T >::each().

◆ empty()

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

Empty the array.

All the occupied memory is freed and the dimension is to set to zero

Definition at line 1427 of file tpl_dynArray.H.

References Aleph::DynArray< T >::cut().

Referenced by Aleph::DynArray< T >::clear(), DataGenerator::few_unique(), DataGenerator::random(), DataGenerator::sawtooth(), Fixed_Relation::set_n(), DataGenerator::sorted_asc(), and DataGenerator::sorted_desc().

◆ ensure_dir()

template<typename T >
void Aleph::DynArray< T >::ensure_dir ( )
inlineprivate

Allocate the directory if the array has none.

An array that was built and has not written yet has no directory, so that building it allocates nothing; nor has one that was moved from, so that moving needs no allocation and stays noexcept. Every writer calls this before indexing the directory; readers treat a missing directory as an array without segments.

Exceptions
bad_allocif the directory cannot be allocated.

Definition at line 399 of file tpl_dynArray.H.

References Aleph::DynArray< T >::allocate_dir(), and Aleph::DynArray< T >::dir.

Referenced by Aleph::DynArray< T >::operator[](), Aleph::DynArray< T >::reserve(), Aleph::DynArray< T >::resize_dir(), and Aleph::DynArray< T >::touch().

◆ ensure_not_empty()

◆ erase()

template<typename T >
void Aleph::DynArray< T >::erase ( T &  item)
inline

See remove(T & item).

Definition at line 1737 of file tpl_dynArray.H.

References Aleph::DynArray< T >::remove().

◆ exist()

template<typename T >
bool Aleph::DynArray< T >::exist ( const size_t  i) const
inline

Return true if the i-th entry is accessible.

By accessible is understood that either the entry has been previously written or the block than would contain it is already allocated,

Parameters
[in]iindex to test

Definition at line 1080 of file tpl_dynArray.H.

References Aleph::DynArray< T >::dir, Aleph::DynArray< T >::dir_size, Aleph::DynArray< T >::index_in_dir(), Aleph::DynArray< T >::index_in_seg(), Aleph::DynArray< T >::max_dim, and Aleph::DynArray< T >::seg_size.

Referenced by Aleph::Matrix_Graph< GT, SA >::copy(), Aleph::DynArray< T >::copy_array(), Aleph::Matrix_Graph< GT, SA >::operator()(), Aleph::Ady_Mat< GT, __Entry_Type, SA >::operator()(), Aleph::matgraph_detail::read_matrix(), Aleph::sequential_search(), TEST(), and TEST_F().

◆ fill_dir_to_null()

template<typename T >
void Aleph::DynArray< T >::fill_dir_to_null ( )
inlineprivatenoexcept

◆ fill_seg_to_null()

template<typename T >
void Aleph::DynArray< T >::fill_seg_to_null ( T **  seg)
inlineprivatenoexcept

Definition at line 373 of file tpl_dynArray.H.

References Aleph::DynArray< T >::seg_size.

Referenced by Aleph::DynArray< T >::allocate_segment().

◆ find_ptr() [1/4]

template<typename T >
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, T &>
T * Aleph::DynArray< T >::find_ptr ( Operation &&  operation)
inline

See find_ptr(Operation & operation).

Definition at line 1624 of file tpl_dynArray.H.

◆ find_ptr() [2/4]

template<typename T >
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const T &>
const T * Aleph::DynArray< T >::find_ptr ( Operation &&  operation) const
inline

See find_ptr(Operation & operation) const.

Definition at line 1632 of file tpl_dynArray.H.

◆ find_ptr() [3/4]

template<typename T >
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, T &>
T * Aleph::DynArray< T >::find_ptr ( Operation &  operation)
inline

Return a pointer to the first entry satisfying a criterion.

Hides LocateFunctions::find_ptr(), whose modifiable traversal would allocate every block it visits. The search reads the entries without allocating; only if an entry never written matches is its block allocated, as a[i] does, so that the pointer refers to the entry. A criterion that only accepts T & is evaluated through the modifiable traversal instead, which allocates the blocks it visits.

Parameters
[in]operationcriterion with signature bool(const T &); it may also be a pointer to member.
Returns
Pointer to the entry, or nullptr if no entry satisfies it.
Exceptions
bad_allocif the block of the found entry cannot be allocated, and anything that operation throws.
Note
O(size()).

Definition at line 1596 of file tpl_dynArray.H.

References Aleph::DynArray< T >::current_dim, Aleph::DynArray< T >::find_ptr(), Aleph::DynArray< T >::index_of_first(), and Aleph::DynArray< T >::touch().

Referenced by Aleph::DynArray< T >::find_ptr().

◆ find_ptr() [4/4]

template<typename T >
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const T &>
const T * Aleph::DynArray< T >::find_ptr ( Operation &  operation) const
inline

Constant overload of find_ptr(); it never allocates memory.

Parameters
[in]operationcriterion with signature bool(const T &).
Returns
Pointer to the entry, to the default value if the entry was never written, or nullptr if no entry satisfies it.
Exceptions
anythingthat operation throws.

Definition at line 1615 of file tpl_dynArray.H.

References Aleph::DynArray< T >::current_dim, Aleph::DynArray< T >::index_of_first(), and Aleph::DynArray< T >::read().

◆ get_block_size()

template<typename T >
size_t Aleph::DynArray< T >::get_block_size ( ) const
inlinenoexcept

Return the block size.

Definition at line 725 of file tpl_dynArray.H.

References Aleph::DynArray< T >::block_size.

◆ get_dir_size()

template<typename T >
size_t Aleph::DynArray< T >::get_dir_size ( ) const
inlinenoexcept

Return the directory size.

Definition at line 713 of file tpl_dynArray.H.

References Aleph::DynArray< T >::dir_size.

◆ get_first() [1/2]

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

Return a modifiable reference to the first item of array (as if this was a queue)

Definition at line 1800 of file tpl_dynArray.H.

References Aleph::DynArray< T >::ensure_not_empty(), and Aleph::DynArray< T >::touch().

Referenced by TEST(), and TEST().

◆ get_first() [2/2]

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

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

Definition at line 1808 of file tpl_dynArray.H.

References Aleph::DynArray< T >::ensure_not_empty(), and Aleph::DynArray< T >::read().

◆ get_it() [1/4]

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

Iterator on the modifiable array, positioned on entry 0.

Returns
the iterator; reading an entry never written allocates it.

Definition at line 2038 of file tpl_dynArray.H.

Referenced by Aleph::Gen_Mo_On_Tree_Node< T, Policy >::build(), main(), and TEST().

◆ get_it() [2/4]

template<typename T >
Const_Iterator Aleph::DynArray< T >::get_it ( ) const
inline

Iterator on the constant array, positioned on entry 0.

Returns
the iterator; it never allocates.

Definition at line 2046 of file tpl_dynArray.H.

◆ get_it() [3/4]

template<typename T >
Iterator Aleph::DynArray< T >::get_it ( const size_t  pos)
inline

Iterator on the modifiable array, positioned on entry pos.

Parameters
[in]posposition of the iterator.
Returns
the iterator.
Exceptions
out_of_rangeif pos >= size().

Definition at line 2056 of file tpl_dynArray.H.

References ah_out_of_range_error_if, Aleph::DynArray< T >::Iterator::set_pos(), and Aleph::DynArray< T >::size().

◆ get_it() [4/4]

template<typename T >
Const_Iterator Aleph::DynArray< T >::get_it ( const size_t  pos) const
inline

Iterator on the constant array, positioned on entry pos.

Parameters
[in]posposition of the iterator.
Returns
the iterator; it never allocates.
Exceptions
out_of_rangeif pos >= size().

Definition at line 2069 of file tpl_dynArray.H.

References ah_out_of_range_error_if, Aleph::Const_Iterator< It >::set_pos(), and Aleph::DynArray< T >::size().

◆ get_last() [1/2]

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

Return a modifiable reference to the last item of array (as if this was a queue)

Definition at line 1816 of file tpl_dynArray.H.

References Aleph::DynArray< T >::ensure_not_empty(), Aleph::DynArray< T >::size(), and Aleph::DynArray< T >::touch().

Referenced by TEST(), and TEST().

◆ get_last() [2/2]

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

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

Definition at line 1824 of file tpl_dynArray.H.

References Aleph::DynArray< T >::ensure_not_empty(), Aleph::DynArray< T >::read(), and Aleph::DynArray< T >::size().

◆ get_num_blocks()

template<typename T >
size_t Aleph::DynArray< T >::get_num_blocks ( ) const
inlinenoexcept

Return the number of blocks consumed by the array.

Definition at line 748 of file tpl_dynArray.H.

References Aleph::DynArray< T >::num_blocks.

◆ get_seg_size()

template<typename T >
size_t Aleph::DynArray< T >::get_seg_size ( ) const
inlinenoexcept

Return the segment size.

Definition at line 719 of file tpl_dynArray.H.

References Aleph::DynArray< T >::seg_size.

◆ index_in_block()

◆ index_in_dir()

◆ index_in_seg()

◆ index_of_first()

template<typename T >
template<class Operation >
size_t Aleph::DynArray< T >::index_of_first ( Operation &  operation) const
inlineprivate

◆ insert() [1/2]

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

Insert a copy of item at the beginning of the array.

Parameters
[in]itemValue to insert; it may be an entry of this array, as in a.insert(a.access(1)).
Returns
Reference to the inserted copy, now entry 0.
Exceptions
std::bad_alloc,std::length_errorif the array has already Max_Dim_Allowed entries, or an exception from T.
Note
O(n): every entry shifts one position. The array is unchanged if the copy or the allocation throws.

Definition at line 1671 of file tpl_dynArray.H.

References Aleph::DynArray< T >::append(), Aleph::open_gap(), and Aleph::DynArray< T >::touch().

Referenced by Aleph::to_set().

◆ insert() [2/2]

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

Move item to the beginning of the array.

Parameters
[in]itemValue to insert; it may be an entry of this array, which is then left moved from.
Returns
Reference to the inserted item, now entry 0.
Exceptions
std::bad_alloc,std::length_errorif the array has already Max_Dim_Allowed entries, or an exception from T.
Note
O(n): every entry shifts one position. item is untouched if the allocation throws.

Definition at line 1690 of file tpl_dynArray.H.

References Aleph::DynArray< T >::append(), Aleph::DynArray< T >::current_dim, Aleph::open_gap(), and Aleph::DynArray< T >::touch().

◆ is_empty()

template<typename T >
bool Aleph::DynArray< T >::is_empty ( ) const
inlinenoexcept

◆ max_size()

template<typename T >
size_t Aleph::DynArray< T >::max_size ( ) const
inlinenoexcept

Return the maximum allowed dimension (or the maximum number of elements that could have the array treated as a container).

Be careful with the fact that this bound_min_clock is not related to available memory

Definition at line 742 of file tpl_dynArray.H.

References Aleph::DynArray< T >::max_dim.

◆ modulus_by_block_size()

template<typename T >
size_t Aleph::DynArray< T >::modulus_by_block_size ( const size_t  number) const
inlineprivatenoexcept

◆ modulus_from_index_in_dir()

template<typename T >
size_t Aleph::DynArray< T >::modulus_from_index_in_dir ( const size_t  i) const
inlineprivatenoexcept

◆ mutable_traverse()

template<typename T >
template<class Operation >
bool Aleph::DynArray< T >::mutable_traverse ( Operation &  operation)
inlineprivate

◆ next2Pow()

template<typename T >
static size_t Aleph::DynArray< T >::next2Pow ( const size_t  number)
inlinestaticprivatenoexcept

Definition at line 527 of file tpl_dynArray.H.

References ceil(), and log().

◆ nth() [1/2]

template<typename T >
T & Aleph::DynArray< T >::nth ( const size_t  n)
inline

Return a modifiable reference to entry n.

Hides LocateFunctions::nth(), whose traversal would keep the address of the short-lived copy handed out for an entry never written. As a[i] does, this modifiable access allocates the entry's block; the constant overload and read() do not.

Parameters
[in]nindex of the entry.
Returns
Reference to entry n.
Exceptions
out_of_rangeif n >= size().
bad_allocif the block of entry n cannot be allocated.
Note
O(1), unlike the linear search of the generic method.

Definition at line 1514 of file tpl_dynArray.H.

References ah_out_of_range_error_if, Aleph::DynArray< T >::current_dim, and Aleph::DynArray< T >::touch().

◆ nth() [2/2]

template<typename T >
const T & Aleph::DynArray< T >::nth ( const size_t  n) const
inline

Return entry n of a constant array; equivalent to read(n).

Parameters
[in]nindex of the entry.
Returns
Constant reference to entry n, or to the default value if the entry was never written.
Exceptions
out_of_rangeif n >= size().
Note
O(1). Never allocates memory.

Definition at line 1528 of file tpl_dynArray.H.

References Aleph::DynArray< T >::read().

◆ nth_ne() [1/2]

template<typename T >
T & Aleph::DynArray< T >::nth_ne ( const size_t  n)
inline

Return a modifiable reference to entry n without checking n.

Parameters
[in]nindex of the entry; it must be smaller than size().
Returns
Reference to entry n, whose block is allocated if needed.
Exceptions
bad_allocif the block of entry n cannot be allocated.

Definition at line 1538 of file tpl_dynArray.H.

References Aleph::DynArray< T >::current_dim, and Aleph::DynArray< T >::touch().

◆ nth_ne() [2/2]

template<typename T >
const T & Aleph::DynArray< T >::nth_ne ( const size_t  n) const
inlinenoexcept

Return entry n of a constant array without checking n.

Parameters
[in]nindex of the entry; it must be smaller than size().
Returns
Constant reference to entry n, or to the default value if the entry was never written.
Note
Never allocates memory.

Definition at line 1550 of file tpl_dynArray.H.

References Aleph::DynArray< T >::current_dim, Aleph::DynArray< T >::default_initial_value, and test().

◆ operator()() [1/2]

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

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

Definition at line 1068 of file tpl_dynArray.H.

References Aleph::DynArray< T >::access().

◆ operator()() [2/2]

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

See access(const size_t i).

Definition at line 1061 of file tpl_dynArray.H.

References Aleph::DynArray< T >::access().

◆ operator=() [1/2]

template<typename T >
DynArray< T > & Aleph::DynArray< T >::operator= ( const DynArray< T > &  array)
inline

Copy assignment: *this becomes an exact copy of array.

Parameters
[in]arraysource of copy
Returns
*this
Exceptions
bad_allocif there is no enough memory
Note
Strong guarantee: the copy is built first and then swapped in, so *this is unchanged if copying throws. The default value is copied, and entries that array never wrote are not left with the previous contents of *this.

Definition at line 950 of file tpl_dynArray.H.

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

◆ operator=() [2/2]

template<typename T >
DynArray & Aleph::DynArray< T >::operator= ( DynArray< T > &&  other)
inlinenoexcept

Move assignment: swap the contents with other.

Parameters
[in,out]othersource; it receives the previous contents.
Returns
*this.
Exceptions
anythingthat swapping two T throws.

Definition at line 1025 of file tpl_dynArray.H.

References Aleph::DynArray< T >::swap().

◆ operator[]() [1/2]

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

Access entry i of a modifiable array through a proxy.

Assigning to the proxy writes the entry and extends size() to i + 1 if needed. Converting it to T &, as in a[i] += 1 or int x = a[i], allocates the entry's block, since a read cannot be told apart from a write; read() reads without allocating.

Parameters
[in]iindex of the entry; it may be greater than size().
Returns
Proxy to entry i.
Exceptions
bad_allocif the directory cannot be grown.
length_errorif i is not less than Max_Dim_Allowed; the array is then as it was.

Definition at line 1490 of file tpl_dynArray.H.

References Aleph::DynArray< T >::ensure_dir(), Aleph::DynArray< T >::max_dim, and Aleph::DynArray< T >::resize_dir().

◆ operator[]() [2/2]

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

Read entry i of a constant array; equivalent to read(i).

Parameters
[in]iindex of the entry, smaller than size().
Returns
Constant reference to the entry or to the default value.
Exceptions
out_of_rangeif i >= size().
Note
Never allocates memory. It returns const T &, not a proxy, so writing through a constant array does not compile.

Definition at line 1472 of file tpl_dynArray.H.

References Aleph::DynArray< T >::read().

◆ pop()

◆ push() [1/2]

template<typename T >
void Aleph::DynArray< T >::push ( const T &  data)
inline

See append(const T & data).

Definition at line 1701 of file tpl_dynArray.H.

References Aleph::DynArray< T >::append().

◆ push() [2/2]

template<typename T >
T & Aleph::DynArray< T >::push ( T &&  data)
inline

See append(T && data).

Definition at line 1707 of file tpl_dynArray.H.

References Aleph::DynArray< T >::append().

◆ put() [1/2]

template<typename T >
void Aleph::DynArray< T >::put ( const T &  data)
inline

See append(const T & data).

Definition at line 1713 of file tpl_dynArray.H.

References Aleph::DynArray< T >::append().

◆ put() [2/2]

template<typename T >
T & Aleph::DynArray< T >::put ( T &&  data)
inline

See append(T && data).

Definition at line 1719 of file tpl_dynArray.H.

References Aleph::DynArray< T >::append().

◆ read()

template<typename T >
const T & Aleph::DynArray< T >::read ( const size_t  i) const
inline

Read entry i without allocating memory.

Neither the directory, nor a segment, nor a block is allocated: an entry whose block was never allocated reads as the default value (see set_default_initial_value()). Every other entry that was never written holds the default value too, since new blocks are filled with it.

Parameters
[in]iindex of the entry, smaller than size().
Returns
Constant reference to the entry or to the default value.
Exceptions
out_of_rangeif i >= size().
Note
O(1).

Definition at line 1454 of file tpl_dynArray.H.

References ah_out_of_range_error_if, Aleph::DynArray< T >::current_dim, Aleph::DynArray< T >::default_initial_value, and test().

Referenced by Aleph::DynArray< T >::find_ptr(), Aleph::DynArray< T >::get_first(), Aleph::DynArray< T >::get_last(), Aleph::DynArray< T >::nth(), Aleph::DynArray< T >::operator[](), TEST(), TEST(), and Aleph::DynArray< T >::top().

◆ release_all_segments_and_blocks()

template<typename T >
void Aleph::DynArray< T >::release_all_segments_and_blocks ( )
inlineprivatenoexcept

◆ release_block()

template<typename T >
void Aleph::DynArray< T >::release_block ( T *&  block)
inlineprivatenoexcept

◆ release_blocks_and_segment()

template<typename T >
void Aleph::DynArray< T >::release_blocks_and_segment ( T **&  seg)
inlineprivatenoexcept

◆ release_dir()

template<typename T >
void Aleph::DynArray< T >::release_dir ( )
inlineprivatenoexcept

◆ release_segment()

◆ remove()

template<typename T >
void Aleph::DynArray< T >::remove ( T &  item)
inline

Given a valid reference to an item in the array, it removes it and decrease the dimension.

Parameters
[in]itemvalid reference to the item to remove

Definition at line 1729 of file tpl_dynArray.H.

References Aleph::DynArray< T >::cut_ne(), Aleph::DynArray< T >::ensure_not_empty(), Aleph::DynArray< T >::size(), and Aleph::DynArray< T >::touch().

Referenced by Aleph::DynArray< T >::erase(), main(), Aleph::DynArray_Set< T, Equal >::remove_all(), Aleph::DynArray_Set< T, Equal >::remove_one(), and TEST().

◆ reserve() [1/2]

template<typename T >
void Aleph::DynArray< T >::reserve ( const size_t  dim)
inline

Allocate the first dim entries and make size() at least dim.

After the call, every entry in [0, dim) can be accessed with access() or operator()(), which do not check allocation. Entries that were never written hold the default value.

Parameters
[in]dimnumber of entries to allocate.
Exceptions
bad_allocif there is no enough memory.
length_errorif dim is greater than Max_Dim_Allowed; the array is then as it was.
Warning
Unlike std::vector::reserve() and Array::reserve(), this does not just reserve capacity: size() becomes dim if it was smaller. Do not follow it with append(), which writes after those dim entries; write them with a(i) = ... or a[i] = .... To fill a DynArray with append() there is nothing to reserve: each block is allocated when needed.

Definition at line 1314 of file tpl_dynArray.H.

References dim(), and Aleph::DynArray< T >::reserve().

◆ reserve() [2/2]

template<typename T >
void Aleph::DynArray< T >::reserve ( const size_t  l,
const size_t  r 
)
inline

Allocate a range of entries.

reserve(l, r) assures that all the entries comprised between l and r are allocated. After a successful call, any entry between l and r can be surely accessed with access(), and size() is at least r + 1 (see the warning of reserve(size_t)).

Parameters
[in]llower index
[in]rupper index
Exceptions
bad_allocif there is no enough memory. If allocating a segment or a block fails, the segments and blocks previously allocated by this call are released before the exception propagates.
domain_errorif l is greater than r
length_errorif r is not less than Max_Dim_Allowed; the array is then as it was.
Note
If every entry of the range is already allocated, the call performs no heap allocation.

Definition at line 1202 of file tpl_dynArray.H.

References ah_domain_error_if, Aleph::DynArray< T >::allocate_block(), Aleph::DynArray< T >::allocate_segment(), FunctionalMethods< DynArray< T >, T >::and, Aleph::Array< T >::append(), Aleph::DynArray< T >::current_dim, Aleph::DynArray< T >::dir, Aleph::DynArray< T >::ensure_dir(), Aleph::DynArray< T >::index_in_dir(), Aleph::DynArray< T >::index_in_seg(), k, l, Aleph::DynArray< T >::max_dim, r, Aleph::DynArray< T >::release_block(), Aleph::DynArray< T >::release_segment(), Aleph::Array< T >::reserve(), Aleph::DynArray< T >::resize_dir(), Aleph::DynArray< T >::seg_size, and Aleph::Array< T >::size().

Referenced by Aleph::DynArray< T >::DynArray(), Fixed_Relation::Fixed_Relation(), Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::Floyd_All_Shortest_Paths(), Aleph::IO_Graph< GT, Load_Node, Store_Node, Load_Arc, Store_Arc, NF, AF >::Loaded_Nodes::Loaded_Nodes(), Aleph::DynArray< T >::adjust(), DynArraySortTest::build_array(), check(), Aleph::Compute_Cut_Nodes< GT, SA >::compute_blocks(), Aleph::Random_Digraph< GT, Init_Node, Init_Arc >::connect(), create_graph(), Aleph::Bellman_Ford< GT, Distance, Ait, NAit, SA >::extract_min_spanning_tree(), Aleph::Random_Graph< GT, Init_Node, Init_Arc >::join_through_the_complement(), LLVMFuzzerTestOneInput(), main(), Aleph::DynArray< T >::reserve(), Fixed_Relation::set_n(), Aleph::settree_to_vector(), DynArraySortTest::SetUp(), HashStats< HashTbl >::stats(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST_F(), Relation::verify_if_add_new_points(), Aleph::Prefix_Tree_Map< T >::words(), and Aleph::Cnode::words().

◆ resize_dir()

◆ reverse()

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

Reverse the order of items in an array.

Definition at line 1760 of file tpl_dynArray.H.

References Aleph::DynArray< T >::current_dim, and Aleph::DynArray< T >::touch().

Referenced by LLVMFuzzerTestOneInput().

◆ set_default_initial_value() [1/2]

template<typename T >
void Aleph::DynArray< T >::set_default_initial_value ( const T &  value)
inlinenoexcept

Set the default value.

The default value of a dynamic array is the value to be returned when entries not still written are accessed.

Parameters
[in]valuedefault value
Exceptions
anythingthat the copy assignment of T throws.
Note
Set it before writing. A block that is already allocated keeps the default value it was filled with; only blocks allocated afterwards, and reads of entries whose block does not exist, use the new value.

Definition at line 765 of file tpl_dynArray.H.

References Aleph::DynArray< T >::default_initial_value, Aleph::DynArray< T >::default_initial_value_ptr, and value.

Referenced by Aleph::Matrix_Graph< GT, SA >::copy(), Aleph::Matrix_Graph< GT, SA >::copy(), and TEST().

◆ set_default_initial_value() [2/2]

template<typename T >
void Aleph::DynArray< T >::set_default_initial_value ( T &&  value = T())
inlinenoexcept

See set_default_initial_value(const T & value).

Exceptions
anythingthat swapping two T throws.

Definition at line 775 of file tpl_dynArray.H.

References Aleph::DynArray< T >::default_initial_value, Aleph::DynArray< T >::default_initial_value_ptr, and value.

◆ size()

template<typename T >
size_t Aleph::DynArray< T >::size ( ) const
inlinenoexcept

Return the current dimension of array.

According to usage style, this could represent the number of items stored in the array seen as a container

Definition at line 733 of file tpl_dynArray.H.

References Aleph::DynArray< T >::current_dim.

Referenced by OhashCommon< HashTbl, Key >::Stats::Stats(), Pointer_Table::allocate_above_heap(), Aleph::Compiler_Line_Frontend::analyze(), Aleph::analyze_dataflow_function(), Aleph::Compiler_Semantic_Analyzer::analyze_imports(), Aleph::Compiler_Typed_Semantic_Analyzer::analyze_stmt(), Aleph::DynArray< T >::append(), Aleph::Compiler_Module_Semantic_Environment_Detail::append_unique_name(), assign_arcs(), assign_distance(), assign_parrectangle(), assign_rectangle(), assign_scratch(), assign_shadow(), assign_tag(), assign_triangle(), assign_without_arc(), assign_without_node(), assign_xoffset(), assign_yoffset(), Aleph::Compiler_IR_Lowering::Module_Builder::bind(), Aleph::bubble_sort(), build_tree(), Aleph::Interpreter_Runtime::call_hir_function(), Pointer_Table::cleanup_free_table(), Aleph::Compiler_Typed_Semantic_Analyzer::collect_binding_free_type_variables(), Aleph::compiler_dump_bytecode_globals(), Aleph::compiler_dump_cfg_function(), Aleph::compiler_dump_dataflow_analysis(), Aleph::compiler_dump_ir_function(), Aleph::compiler_dump_ssa_function(), Aleph::compiler_link_module_surfaces(), Aleph::compiler_render_module_metadata(), Aleph::compiler_render_module_order(), Aleph::compiler_resolve_module_order(), Aleph::Compiler_SSA_Detail::compute_dominance_info(), Aleph::Compiler_Dataflow_Detail::compute_reachability(), Aleph::Compiler_SSA_Detail::compute_reachable_blocks(), Random_Network_Flow< Net >::connect_ranks(), Aleph::DynArray_Set< T, Equal >::count(), demo_city_coordinates(), demo_convex_hull_cities(), demo_convex_hull_performance(), demo_department_codes(), demo_dynarray(), demo_encoding_decoding(), demo_hash_dispatcher(), demo_performance(), demo_prefix_search(), demo_regions_menu(), demo_text_processor(), demo_variadic_dispatcher(), Aleph::dynarray_to_Array(), Aleph::dynarray_to_DynDlist(), Aleph::dynarray_to_DynList(), Aleph::DynArray_to_vector(), Aleph::eliminate_dead_code(), Aleph::Compiler_C_Backend::Emitter::emit_instruction(), Aleph::DynArray< T >::Iterator::end(), Aleph::Compiler_Driver::execute_files(), Aleph::Compiler_Generic_Driver::execute_files(), Aleph::Compiler_Bytecode_VM::execute_host_call(), file_to_dynarrays(), Aleph::Compiler_Driver::find_artifact(), Aleph::Compiler_Line_Frontend::find_artifact(), Aleph::Compiler_IR_Lowering::Module_Builder::find_function_id(), Aleph::Compiler_Driver::find_source_index(), Aleph::Compiler_Line_Frontend::find_source_index(), Aleph::Compiler_MVP_Frontend::find_source_index(), Aleph::Compiler_Line_Frontend::flatten_program_in_import_order(), Aleph::Compiler_Dataflow_Detail::format_slot_constants(), Pointer_Table::frees(), generate_split_lines(), Aleph::DynArray< T >::Iterator::get_curr(), Aleph::DynArray< T >::get_it(), Aleph::DynArray< T >::get_it(), Aleph::DynArray< T >::get_last(), Aleph::DynArray< T >::get_last(), Aleph::DynArray< T >::Iterator::has_curr(), Aleph::heapsort(), Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::index_node(), Pointer_Table::insert_in_free_table(), Aleph::Compiler_Typed_Semantic_Analyzer::instantiate_type(), Aleph::Compiler_Bytecode_Detail::intern_constant(), Aleph::interpreter_values_equal(), Aleph::introsort(), Pointer_Table::invariant(), Aleph::DynArray< T >::is_empty(), Moved_From_Case< Floyd_All_Shortest_Paths< Dgraph > >::is_empty(), Aleph::DynArray< T >::Iterator::is_last(), Aleph::Random_Graph< GT, Init_Node, Init_Arc >::join_any_odd_nodes(), Aleph::Random_Digraph< GT, Init_Node, Init_Arc >::join_any_unbalanced_nodes(), Aleph::Random_Graph< GT, Init_Node, Init_Arc >::join_through_the_complement(), Aleph::Compiler_Typed_Semantic_Analyzer::leave_scope(), LLVMFuzzerTestOneInput(), load_key_option(), Aleph::Compiler_Line_Frontend::load_sources(), Aleph::Compiler_MVP_Frontend::load_sources(), Aleph::Compiler_IR_Lowering::Module_Builder::lookup(), Aleph::Compiler_IR_Lowering::Module_Builder::lower_expr(), Aleph::Compiler_Bytecode_Lowering::lower_function(), Aleph::Compiler_IR_Lowering::Module_Builder::lower_function_body(), Aleph::Compiler_Line_Frontend::lower_hir(), Aleph::Compiler_Line_Frontend::lower_ir(), Aleph::Compiler_CFG_Lowering::lower_statement_sequence(), Aleph::Compiler_CFG_Lowering::lower_stmt(), Aleph::Compiler_IR_Lowering::Module_Builder::lower_stmt(), main(), main(), Aleph::Compiler_Dataflow_Detail::mark_value_used(), Aleph::Compiler_Driver::merge_modules_from_order(), Aleph::Compiler_MVP_Frontend::merge_modules_from_order(), Aleph::DynArray< T >::Iterator::next(), Aleph::Compiler_SSA_Detail::normalize_ir_function(), Aleph::Compiler_Line_Frontend::parse(), Aleph::Compiler_MVP_Frontend::parse(), Aleph::Compiler_Line_Frontend::parse_function_line(), Aleph::Compiler_Line_Frontend::parse_import_line(), Aleph::Compiler_Line_Frontend::parse_let_line(), Aleph::Compiler_Driver::parse_registered_sources(), Aleph::DynArray< T >::pop(), Aleph::Compiler_SSA_Detail::predecessor_index(), Aleph::Compiler_Typed_Semantic_Analyzer::predeclare_function(), Aleph::Compiler_IR_Lowering::Module_Builder::preload_global_bindings(), Aleph::Compiler_Driver::prepare_inputs(), print_dynarray(), OhashCommon< HashTbl, Key >::print_stats(), HashStats< HashTbl >::print_stats(), Aleph::Compiler_Bytecode_VM::push_frame(), Aleph::quicksort(), Aleph::random_select(), Aleph::Compiler_Bytecode_VM::read_callee_and_arguments(), reassign_key(), Aleph::Compiler_Driver::record_ast_artifacts(), Aleph::Compiler_Driver::record_import_order_artifact(), Aleph::Compiler_Typed_Semantic_Analyzer::remember_function_annotation_type_variables(), Aleph::DynArray< T >::remove(), Aleph::DynArray_Set< T, Equal >::remove_all(), Pointer_Table::remove_pointer(), Aleph::Compiler_Driver_Detail::render_messages(), Aleph::Compiler_Ast_Context::reset(), Aleph::DynArray< T >::Iterator::reset_last(), Aleph::Compiler_Driver::resolve_import_order(), Aleph::DynArray_Set< T, Equal >::search(), Aleph::selection_sort(), Aleph::Compiler_Dataflow_Bit_Set::set(), Aleph::Compiler_Type_Context::set_struct_fields(), Aleph::shellsort(), Aleph::Compiler_Dataflow_Bit_Set::size(), Pointer_Table::size(), Dynamic_Event_Table< Signature >::size(), HashStats< HashTbl >::stats(), Aleph::ODhashTable< Key, Cmp >::stats(), Aleph::OLhashTable< Key, Cmp >::stats(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), Aleph::Compiler_Dataflow_Bit_Set::test(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), test_DynSet(), test_DynSetLinHash(), TEST_F(), Aleph::DynArray< T >::to_array(), to_array(), to_dyndlist(), to_dynlist(), Aleph::DynArray< T >::top(), Aleph::DynArray< T >::top(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), Moved_From_Case< Floyd_All_Shortest_Paths< Dgraph > >::use(), Aleph::validate_cfg_function(), Aleph::validate_dataflow_analysis(), Aleph::validate_ir_function(), Aleph::validate_ssa_function(), Aleph::Compiler_Dataflow_Detail::value_constant(), and Aleph::Xml_Graph< GT, Node_Reader, Arc_Reader, Node_Writer, Arc_Writer >::write_graph().

◆ swap()

template<typename T >
void Aleph::DynArray< T >::swap ( DynArray< T > &  array)
inlinenoexcept

◆ test()

template<typename T >
T * Aleph::DynArray< T >::test ( const size_t  i) const
inlinenoexcept

Test if the i-th entry es writable,.

test(i) inspects if the entry i is already allocated. If affirmative, then a pointer to the entry in the array is returned. Otherwise, nullptr is returned.

Parameters
[in]iindex to test.
Returns
nullptr if the entry is not allocated; a valid pointer inside the array otherwise

Definition at line 1112 of file tpl_dynArray.H.

References Aleph::DynArray< T >::dir, Aleph::DynArray< T >::index_in_block(), Aleph::DynArray< T >::index_in_dir(), Aleph::DynArray< T >::index_in_seg(), and Aleph::DynArray< T >::max_dim.

Referenced by Aleph::DynArray< T >::Iterator::get_curr_ne().

◆ to_array()

template<typename T >
Array< T > Aleph::DynArray< T >::to_array ( ) const
inline

Copy contents into Aleph::Array (requires copyable elements).

Definition at line 1749 of file tpl_dynArray.H.

References Aleph::Array< T >::append(), Aleph::Array< T >::reserve(), and Aleph::DynArray< T >::size().

Referenced by Aleph::Two_Sat< GT >::add_at_most_one().

◆ top() [1/2]

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

Return a modifiable reference to the last item of stack.

Definition at line 1784 of file tpl_dynArray.H.

References Aleph::DynArray< T >::ensure_not_empty(), Aleph::DynArray< T >::size(), and Aleph::DynArray< T >::touch().

◆ top() [2/2]

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

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

Definition at line 1792 of file tpl_dynArray.H.

References Aleph::DynArray< T >::ensure_not_empty(), Aleph::DynArray< T >::read(), and Aleph::DynArray< T >::size().

◆ touch()

template<typename T >
T & Aleph::DynArray< T >::touch ( const size_t  i)
inline

Touch the entry i.

touch(i) testes if the block that would contain to i is already allocated. If this is not the case, then the block, and eventually the segment, is allocated. If everything is ok, the method returns a valid pointer to the entry inside the array.

touch(i) is a concise and effective way to test and eventually to allocate memory for a new entry.

Parameters
[in]iindex to touch
Exceptions
bad_allocif there is no enough memory
length_errorif i is not less than Max_Dim_Allowed; the array is then as it was.
See also
cut

Definition at line 1145 of file tpl_dynArray.H.

References Aleph::DynArray< T >::allocate_block(), Aleph::DynArray< T >::allocate_segment(), Aleph::DynArray< T >::current_dim, Aleph::DynArray< T >::dir, Aleph::DynArray< T >::ensure_dir(), Aleph::DynArray< T >::index_in_block(), Aleph::DynArray< T >::index_in_dir(), Aleph::DynArray< T >::index_in_seg(), Aleph::DynArray< T >::max_dim, Aleph::DynArray< T >::release_segment(), and Aleph::DynArray< T >::resize_dir().

Referenced by Aleph::IO_Graph< GT, Load_Node, Store_Node, Load_Arc, Store_Arc, NF, AF >::Loaded_Nodes::add(), Aleph::DynArray< T >::append(), Aleph::Matrix_Graph< GT, SA >::copy(), Aleph::DynArray< T >::each(), Aleph::Bellman_Ford< GT, Distance, Ait, NAit, SA >::extract_min_spanning_tree(), Aleph::DynArray< T >::find_ptr(), Aleph::DynArray< T >::Iterator::get_curr_ne(), Aleph::DynArray< T >::get_first(), Aleph::DynArray< T >::get_last(), Aleph::DynArray< T >::insert(), Aleph::DynArray< T >::insert(), main(), Aleph::DynArray< T >::mutable_traverse(), Aleph::DynArray< T >::nth(), Aleph::DynArray< T >::nth_ne(), Aleph::Ady_Mat< GT, __Entry_Type, SA >::operate_all_arcs_list_graph(), Aleph::Ady_Mat< GT, __Entry_Type, SA >::operate_all_arcs_list_graph(), Aleph::Ady_Mat< GT, __Entry_Type, SA >::operate_all_arcs_matrix(), Aleph::Ady_Mat< GT, __Entry_Type, SA >::operate_all_arcs_matrix(), Aleph::Matrix_Graph< GT, SA >::operator()(), Aleph::Ady_Mat< GT, __Entry_Type, SA >::operator()(), Aleph::DynArray< T >::remove(), Aleph::DynArray< T >::reverse(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST_F(), TEST_F(), Aleph::DynArray< T >::top(), and HashStats< HashTbl >::update_stat_len().

◆ traverse() [1/4]

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

See traverse(Operation & operation).

Definition at line 2180 of file tpl_dynArray.H.

◆ traverse() [2/4]

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

See traverse(Operation & operation) const.

Definition at line 2171 of file tpl_dynArray.H.

◆ traverse() [3/4]

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

Traverse a modifiable array; operation receives modifiable references, with the signature bool operation(T & item).

Parameters
[in]operation
Returns
true if all items are traversed; false otherwise
Exceptions
bad_allocif the block of an entry never written cannot be allocated, and anything that operation throws.
Note
The block of an entry never written is allocated before it is visited, as a[i] does, so whatever operation writes stays in the array. To read without allocating, traverse a constant reference, as std::as_const(a).traverse(op).

Definition at line 2163 of file tpl_dynArray.H.

References Aleph::DynArray< T >::mutable_traverse().

◆ traverse() [4/4]

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

Traverse a constant array and execute a conditioned operation, which must have the signature:

bool operation(const T & item)
std::decay_t< typename HeadC::Item_Type > T
Definition ah-zip.H:152

If

operation()

returns false then the traversal is stopped; otherwise the traverse move to the next item.

Parameters
[in]operation
Returns
true if all items are traversed; false otherwise
Exceptions
anythingthat operation throws.
Note
It never allocates memory. Entries that were never written are passed as the default value.

Definition at line 2143 of file tpl_dynArray.H.

References Aleph::DynArray< T >::const_traverse().

Referenced by TEST().

◆ two_raised()

template<typename T >
static size_t Aleph::DynArray< T >::two_raised ( const size_t  n)
inlinestaticprivate

Return 2^n.

Parameters
[in]nExponent.
Returns
2 raised to n.
Exceptions
std::overflow_errorif 2^n does not fit in a size_t.

Definition at line 257 of file tpl_dynArray.H.

References ah_overflow_error_if, and Aleph::DynArray< T >::Max_Bits_Allowed.

Referenced by Aleph::DynArray< T >::DynArray(), Aleph::DynArray< T >::compute_dim(), Aleph::DynArray< T >::index_in_dir(), Aleph::DynArray< T >::index_in_seg(), and Aleph::DynArray< T >::resize_dir().

Member Data Documentation

◆ block_size

◆ current_dim

◆ default_initial_value

◆ default_initial_value_ptr

◆ Default_Pow_Block

template<typename T >
const size_t Aleph::DynArray< T >::Default_Pow_Block = 12
static

Default two power for segment size.

Definition at line 228 of file tpl_dynArray.H.

Referenced by Aleph::DynArray< T >::compute_sizes().

◆ Default_Pow_Dir

template<typename T >
const size_t Aleph::DynArray< T >::Default_Pow_Dir = 6
static

The type of element stored in the array.

Definition at line 226 of file tpl_dynArray.H.

Referenced by Aleph::DynArray< T >::compute_sizes().

◆ Default_Pow_Seg

template<typename T >
const size_t Aleph::DynArray< T >::Default_Pow_Seg = 8
static

Default two power for directory size.

Definition at line 227 of file tpl_dynArray.H.

Referenced by Aleph::DynArray< T >::compute_sizes().

◆ dir

◆ dir_size

◆ mask_block

template<typename T >
size_t Aleph::DynArray< T >::mask_block = block_size - 1
private

◆ mask_seg

template<typename T >
size_t Aleph::DynArray< T >::mask_seg = seg_size - 1
private

Definition at line 323 of file tpl_dynArray.H.

Referenced by Aleph::DynArray< T >::swap().

◆ mask_seg_plus_block

template<typename T >
size_t Aleph::DynArray< T >::mask_seg_plus_block = two_raised(seg_plus_block_pow) - 1
mutableprivate

◆ Max_Bits_Allowed

template<typename T >
const size_t Aleph::DynArray< T >::Max_Bits_Allowed = 8 * sizeof(size_t)
staticprivate

Default two power for block size.

Definition at line 231 of file tpl_dynArray.H.

Referenced by Aleph::DynArray< T >::two_raised().

◆ max_dim

◆ Max_Dim_Allowed

template<typename T >
const unsigned long long Aleph::DynArray< T >::Max_Dim_Allowed = 256 * 1024 * 1024 * 1024ull
static

Maximum dimension allowed.

Definition at line 235 of file tpl_dynArray.H.

Referenced by Aleph::DynArray< T >::DynArray(), Aleph::DynArray< T >::DynArray(), and Aleph::DynArray< T >::resize_dir().

◆ Max_Pow_Block

template<typename T >
const size_t Aleph::DynArray< T >::Max_Pow_Block = (Max_Bits_Allowed - Default_Pow_Dir - Default_Pow_Seg - 1)
staticprivate

Definition at line 238 of file tpl_dynArray.H.

◆ num_blocks

◆ num_segs

template<typename T >
size_t Aleph::DynArray< T >::num_segs = 0
private

◆ pow_block

◆ pow_dir

template<typename T >
size_t Aleph::DynArray< T >::pow_dir = Default_Pow_Dir
mutableprivate

◆ pow_seg

◆ seg_plus_block_pow

template<typename T >
size_t Aleph::DynArray< T >::seg_plus_block_pow = pow_seg + pow_block
mutableprivate

◆ seg_size


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