245 return static_cast<size_t>(1) << n;
262 static void compute_sizes(
const size_t n,
size_t &d,
size_t &s,
size_t &b)
noexcept
289 static std::tuple<size_t, size_t, size_t>
compute_sizes(
const size_t n)
noexcept
293 return std::make_tuple(d, s, b);
343 for (
size_t i = 0; i <
dir_size; ++i)
351 for (
size_t i = 0; i <
seg_size; ++i)
433 for (
size_t i = 0; i <
seg_size; ++i)
434 if (seg[i] !=
nullptr)
449 for (
size_t i = 0; i <
dir_size; ++i)
450 if (
dir[i] !=
nullptr)
469 static size_t next2Pow(
const size_t number)
noexcept
471 return static_cast<size_t>(
ceil(
log(
static_cast<float>(number)) /
log(2.0)));
498 for (
size_t i = 0; i <
seg_size; i++)
506 for (
size_t i = 0; i <
dir_size; i++)
547 if (
block ==
nullptr)
580 if (
block ==
nullptr)
620 if (
block ==
nullptr)
732 static_assert(std::is_copy_constructible_v<T>,
"No copy constructor for T");
733 static_assert(std::is_move_constructible_v<T>,
"No move constructor for T");
734 static_assert(std::is_copy_assignable_v<T>,
"No copy assign for T");
735 static_assert(std::is_move_assignable_v<T>,
"No move assign for T");
753 static_assert(std::is_default_constructible_v<T>,
"No default constructor for T");
754 static_assert(std::is_copy_constructible_v<T>,
"No copy constructor for T");
755 static_assert(std::is_move_constructible_v<T>,
"No move constructor for T");
756 static_assert(std::is_copy_assignable_v<T>,
"No copy assign for T");
757 static_assert(std::is_move_assignable_v<T>,
"No move assign for T");
778 for (
size_t i = 0; i <
src_array.current_dim; ++i)
827 std::swap(
dir, array.dir);
828 std::swap(
pow_dir, array.pow_dir);
829 std::swap(
pow_seg, array.pow_seg);
833 std::swap(
dir_size, array.dir_size);
834 std::swap(
seg_size, array.seg_size);
836 std::swap(
mask_seg, array.mask_seg);
838 std::swap(
max_dim, array.max_dim);
840 std::swap(
num_segs, array.num_segs);
846 array.default_initial_value_ptr = &array.default_initial_value;
907 if (
dir[pos_in_dir] ==
nullptr)
914 if (
dir[pos_in_dir][pos_in_seg] ==
nullptr)
930 T *
test(
const size_t i)
const noexcept
936 if (
dir[pos_in_dir] ==
nullptr)
940 if (
dir[pos_in_dir][pos_in_seg] ==
nullptr)
968 if (
dir[pos_in_dir] ==
nullptr)
975 if (
dir[pos_in_dir][pos_in_seg] ==
nullptr)
1035 if (
dir[seg_idx] ==
nullptr)
1062 if (
dir[seg_idx] ==
nullptr)
1245 ref = std::move(data);
1263 ret = std::forward<T>(item);
1276 return this->
append(std::forward<T>(data));
1288 return this->
append(std::forward<T>(data));
1299 std::swap(item, this->
access(this->
size() - 1));
1312 return this->
size() == 0;
1321 for (
size_t i = 0; i < this->
size(); ++i)
1332 for (
size_t i = 0, j =
current_dim - 1; i < j; ++i, --j)
1352 return (*
this)[
size() - 1];
1368 return (*
this)[
size() - 1];
1446 <<
"not current item in iterator";
1473 <<
"not current item in iterator";
1530 it.
set_pos(
static_cast<long>(pos));
1541 template <
class Operation>
1577 template <
class Operation>
1584 template <
class Operation>
1591 template <
class Operation>
1598 template <
class Operation>
1605template <
typename T>
1608template <
typename T>
1611template <
typename T>
1614template <
typename T>
1617template <
typename T>
1620template <
typename T>
Variadic constructor macros for containers.
Container traversal and functional operation mixins.
Exception handling system with formatted messages for Aleph-w.
#define ah_length_error_if(C)
Throws std::length_error if condition holds.
#define ah_out_of_range_error_if(C)
Throws std::out_of_range if condition holds.
#define ah_underflow_error_if(C)
Throws std::underflow_error if condition holds.
#define ah_bad_alloc_unless(C)
Throws std::bad_alloc if condition does NOT hold.
#define ah_overflow_error_if(C)
Throws std::overflow_error if condition holds.
#define ah_domain_error_if(C)
Throws std::domain_error if condition holds.
#define ah_invalid_argument_if(C)
Throws std::invalid_argument if condition holds.
DRY (Don't Repeat Yourself) utilities and macros.
#define Special_Ctors(Set_Type, Type)
Generates special constructors for containers.
Iterator traits and STL-compatible iterator wrappers.
Core header for the Aleph-w library.
Utility functions for array manipulation.
size_t size_t int32_t value
Simple dynamic array with automatic resizing and functional operations.
void reserve(size_t cap)
Reserves cap cells into the array.
Contiguous array of bits.
Iterator on the items of array.
void reset_last() noexcept
Reset the iterator to the last item.
long get_pos() const noexcept
Return the ordinal position of current item.
void set_pos(const long pos) noexcept
void reset_first() noexcept
Reset the iterator to the first item.
void prev()
Move the current a position backward.
T & get_curr_ne() const noexcept
Return the current link guaranteeing no exception. Be careful.
bool is_last() const noexcept
Check whether the current item is the last item.
void next()
Advance one position, from the last item to the end if needed.
void end() noexcept
Put the iterator in the end state.
Iterator() noexcept=default
Default constructor creates an "end" iterator.
bool has_curr() const noexcept
Check whether the iterator refers to an item.
void next_ne() noexcept
Move the iterator one position forward guaranteeing no exception.
T & get_curr() const
Return the current item.
void prev_ne() noexcept
exception. Be careful.
Proxy(DynArray< T > &_array, const size_t i) noexcept
Proxy & operator=(const T &data)
bool traverse(Operation &operation)
DynArray(const DynArray< T > &array)
Copy constructor.
void allocate_dir(T ***src_dir)
void release_block(T *&block) noexcept
void allocate_block(T *&block, T *src_block)
T * test(const size_t i) const noexcept
Test if the i-th entry es writable,.
size_t get_block_size() const noexcept
Return the block size.
bool __traverse(Operation &operation)
size_t index_in_dir(const size_t i) const noexcept
size_t index_in_seg(const size_t &i) const noexcept
void adjust(const size_t dim)
Set a new dimension.
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 ...
DynArray & reverse()
Reverse the order of items in an array.
size_t modulus_from_index_in_dir(const size_t i) const noexcept
void swap(DynArray< T > &array) noexcept
Swap in constant time array with this
Array< T > to_array() const
Copy contents into Aleph::Array (requires copyable elements).
size_t get_dir_size() const noexcept
Return the directory size.
void remove(T &item)
Given a valid reference to an item in the array, it removes it and decrease the dimension.
unsigned long long max_dim
static size_t compute_dim(size_t d, size_t s, size_t b) noexcept
void release_dir() noexcept
T Key_Type
The type of element stored in the array.
bool traverse(Operation &&operation)
T & insert(const T &item)
T & get_last() const
Return a modifiable reference to the last item of array (as if this was a queue)
size_t seg_plus_block_pow
static size_t next2Pow(const size_t number) noexcept
Proxy operator[](const size_t i) const
void cut_ne(const size_t new_dim=0)
Iterator get_it(const size_t pos) const
T & get_first() const
Return a modifiable reference to the first item of array (as if this was a queue)
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.
void reserve(const size_t dim)
Assure that the range between 0 and dim is allocated.
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
Set the default value.
void clear() noexcept
Empties the container.
T & append(const T &data)
Copy data to the end of array, increase the dimension and return a modifiable reference to the copied...
void copy_array(const DynArray< T > &src_array)
Copy the items of src_array to this
static const size_t Default_Pow_Seg
Default two power for directory size.
T & touch(const size_t i)
Touch the entry i.
size_t size() const noexcept
Return the current dimension of array.
void release_blocks_and_segment(T **&seg) noexcept
void allocate_segment(T **&seg)
static const size_t Max_Pow_Block
T pop()
Remove the last item of array (as if this was a stack)
bool traverse(Operation &&operation) const
T & access(const size_t i) const noexcept
Fast access without checking allocation and bound_min_clock checking.
static const size_t Default_Pow_Dir
The type of element stored in the array.
T * default_initial_value_ptr
DynArray(const size_t dim=0)
Default constructor.
void fill_dir_to_null() noexcept
void set_default_initial_value(T &&value=T())
static const size_t Default_Pow_Block
Default two power for segment size.
size_t max_size() const noexcept
Return the maximum allowed dimension (or the maximum number of elements that could have the array tre...
void resize_dir(const size_t i)
void release_all_segments_and_blocks() noexcept
bool exist(const size_t i) const
Return true if the i-th entry is accessible.
size_t modulus_by_block_size(const size_t number) const noexcept
size_t divide_by_block_size(const size_t number) const noexcept
static void compute_sizes(const size_t n, size_t &d, size_t &s, size_t &b) noexcept
Given a dimension n, it proposes values for the directory, segment and block sizes.
size_t mask_seg_plus_block
bool traverse(Operation &operation) const
Traverse all the array and execute a conditioned operation must have the signature:
static const unsigned long long Max_Dim_Allowed
Maximum dimension allowed.
T & append(T &&data)
Move data to the end of array, increase the dimension and return a modifiable reference to the copied...
size_t get_seg_size() const noexcept
Return the segment size.
T & top() const
Return a modifiable reference to the last item of stack.
void allocate_segment(T **&seg, T **src_seg)
void allocate_block(T *&block)
DynArray< T > & operator=(const DynArray< T > &array)
Copy assignment.
void release_segment(T **&seg) noexcept
Iterator get_it(const size_t pos)
static std::tuple< size_t, size_t, size_t > compute_sizes(const size_t n) noexcept
Given a dimension n, it proposes values for the directory, segment and block sizes.
void ensure_not_empty(const char *context) const
size_t index_in_block(const size_t i) const noexcept
T & append()
Allocate a new entry to the end of array.
static const size_t Max_Bits_Allowed
Default two power for block size.
bool is_empty() const noexcept
Return true if the array is empty.
void fill_seg_to_null(T **seg) noexcept
next_permutation for DynArray
void empty() noexcept
Empty the array.
DynArray(DynArray &&other) noexcept
Move constructor.
static size_t two_raised(const size_t n) noexcept
void reserve(const size_t l, const size_t r)
Allocate a range of entries.
T & operator()(const size_t i) const noexcept
Mixin providing equality comparison for sequence containers.
Common methods to the Aleph-w ( ) containers.
and
Conditional mapping of the elements of the container.
Common sequential searching methods on containers.
Mixin that adds STL begin()/end() and cbegin()/cend() to Aleph containers.
__gmp_expr< typename __gmp_resolve_expr< T, V >::value_type, __gmp_binary_expr< __gmp_expr< T, U >, __gmp_expr< V, W >, __gmp_dim_function > > dim(const __gmp_expr< T, U > &expr1, const __gmp_expr< V, W > &expr2)
__gmp_expr< T, __gmp_unary_expr< __gmp_expr< T, U >, __gmp_log_function > > log(const __gmp_expr< T, U > &expr)
__gmp_expr< T, __gmp_unary_expr< __gmp_expr< T, U >, __gmp_ceil_function > > ceil(const __gmp_expr< T, U > &expr)
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
Singly linked list implementations with head-tail access.
Main namespace for Aleph-w library functions.
std::decay_t< typename HeadC::Item_Type > T
void open_gap(Tarray &ptr, size_t n, size_t pos=0, size_t num_entries=1)
Open a gap in an array by shifting elements right.
Generic list of items stored in a container.
Dynamic array container with automatic resizing.
Dynamic doubly linked list implementation.