167 <<
"MemArray capacity overflow";
200 <<
"MemArray::expand(): capacity overflow";
202 const size_t mask =
dim - 1;
209 for (
size_t i = 0; i <
dim; ++i)
247 const size_t mask =
dim - 1;
248 for (
size_t i = 0; i <
newsz; ++i)
307 static_assert(std::is_move_constructible_v<T>,
"T must be move constructible");
308 static_assert(std::is_move_assignable_v<T>,
"T must be move assignable");
325 std::swap(
ptr, a.ptr);
326 std::swap(
dim, a.dim);
333 requires(std::is_copy_constructible_v<T> && std::is_copy_assignable_v<T>)
337 for (
size_t i = 0; i <
n; ++i)
350 requires(std::is_copy_constructible_v<T> && std::is_copy_assignable_v<T>)
358 for (
size_t i = 0; i < a.n; ++i)
416 requires std::is_copy_assignable_v<T>
433 ptr[
n] = std::forward<T>(item);
455 requires std::is_copy_assignable_v<T>
472 ptr[0] = std::forward<T>(item);
502 requires std::is_copy_assignable_v<T>
512 return put(std::forward<T>(item));
517 requires std::is_copy_assignable_v<T>
527 return push(std::forward<T>(item));
544 <<
"MemArray::putn(): size overflow";
556 <<
"MemArray::putn(): capacity overflow";
561 for (
size_t i = 0; i <
n; ++i)
572 requires std::is_copy_assignable_v<T>
597 for (
size_t i = 0; i <
n; ++i)
612 <<
"MemArray::get(): invalid number of entries";
673 for (
size_t i = 0, j =
n - 1; i < j; ++i, --j)
674 std::swap(
ptr[i],
ptr[j]);
711 template <
class Operation>
715 for (
size_t i = 0; i <
n; i++)
723 template <
class Operation>
730 template <
class Operation>
737 template <
class Operation>
Exception handling system with formatted messages for Aleph-w.
#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_overflow_error_if(C)
Throws std::overflow_error if condition holds.
DRY (Don't Repeat Yourself) utilities and macros.
Iterator traits and STL-compatible iterator wrappers.
General utility functions and helpers.
Iterator wrapper for C++ raw arrays and circular buffers.
Utility functions for array manipulation.
Iterator wrapper for C++ raw arrays.
Simple, scalable and fast dynamic array.
T & operator()(const size_t i) const noexcept
void reserve(const size_t cap)
Reserves cap cells into the array.
void open_gap(size_t pos=0, size_t num_entries=1)
T & push(T &&item)
Push a copy of item at the beginning of sequence.
bool traverse(Operation &operation)
Traverse all the elements from index 0 to n - 1 and execute operation on each on them.
bool contract(const size_t first=0)
Test if n is lesser than contract_threshold and eventually contract the array half long and copies it...
size_t size() const noexcept
Return the number of elements.
void putn(const size_t more)
Reserve more additional logical slots in the array.
T get_ne(const size_t i=1) noexcept
void clear() noexcept
Alias for empty().
T & first() const
Return a modifiable reference to the first element.
T & access(const size_t i) const noexcept
Return a modifiable reference to the ith element.
T & append(const T &item)
size_t contract_threshold
void empty_and_release()
Empty the array and release all memory.
static constexpr size_t Min_Dim
MemArray(MemArray &&a) noexcept
Construct an array moved of rvalue a
void allocate()
Allocate memory for the current dimension.
bool traverse(Operation &&operation) const
T * get_ptr() const noexcept
Return the current base of array.
bool expand(const size_t first=0)
Test is array is full and if affrimative, then expand the array twice as long and copy the content by...
MemArray(const MemArray &a)
Construct a copy of a
T & push(const T &item)
Push a copy of item at the beginning of sequence.
MemArray & append(const MemArray &a)
MemArray(size_t _dim=Min_Dim)
Construct an array con capacity equal or greater than _dim.
constexpr size_t capacity() const noexcept
The type of element of array.
MemArray & operator=(const MemArray &a)
Assign by copy a to this
T & insert(const T &item)
static size_t next_power_of_two(const size_t requested)
void init_dim(size_t d)
Initialize the dimension of the array to d or to the next two power if d is not a two power.
T & last() const
Return a modifiable reference to the last element.
bool is_valid() const noexcept
void close_gap(size_t pos, size_t num_entries=1)
bool is_empty() const noexcept
Return true is the array is empty.
bool traverse(Operation &&operation)
T pop()
pop() the most recently pushed item
void empty() noexcept
Empties the container.
MemArray & reverse()
Reverse the order of items in array.
const size_t & get_dim() const noexcept
Return the current dimension of array.
T get(const size_t i=1)
Remove i elements from the end.
void swap(MemArray &a) noexcept
Swap in constant time this with a
bool traverse(Operation &operation) const
T & operator[](const size_t i) const
Return a reference to the ith element.
T & put(T &&item)
Move item at the end of sequence.
T & put(const T &item)
Put a copy of item at the end of sequence.
T remove_first()
Remove the first item. Gap is closed.
MemArray & operator=(MemArray &&a) noexcept
Assign by moving a to this
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
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.
bool is_power_of_2(unsigned long x)
Taken from http://stackoverflow.com/questions/3638431/determine-if-an-int-is-a-power-of-2-or-not-in-a...
void close_gap(T *ptr, size_t n, size_t pos, size_t num_entries=1)
Close a gap in an array by shifting elements left.
Simple iterator on elements of array.
Iterator(const MemArray< T > &a) noexcept
Construct an iterator on array a