70#include <initializer_list>
127template <
typename Key,
class Compare = Aleph::less<Key>>
169 for (
size_t i =
keys_.
size() - 1; i > pos; --i)
170 p[i] = std::move(p[i - 1]);
179 for (
size_t i = pos; i < last; ++i)
180 p[i] = std::move(p[i + 1]);
185 catch (
const std::bad_alloc &)
199 for (
size_t i = 0; i <
keys_.
size(); ++i)
203 p[
m] = std::move(p[i]);
212 catch (
const std::bad_alloc &)
255 template <std::input_iterator It>
259 for (; first != last; ++first)
270 FlatSet(std::initializer_list<Key>
l,
const Compare &
cmp = Compare())
294 std::swap(
cmp_, s.cmp_);
399 std::pair<const_iterator, const_iterator>
equal_range(
const Key &
k)
const
410 const Key &
nth(
size_t i)
const
465 std::pair<const_iterator, bool>
insert(
const Key &
k)
469 return {
begin() + pos,
false};
472 return {
begin() + pos,
true};
481 std::pair<const_iterator, bool>
insert(Key &&
k)
485 return {
begin() + pos,
false};
488 return {
begin() + pos,
true};
502 template <
class...
Args>
505 return insert(Key(std::forward<Args>(
args)...));
531 const size_t pos = it -
begin();
534 return begin() + pos;
578 template <
class Operation>
583 for (
size_t i = 0; i <
m; ++i)
604 return not (*
this == s);
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.
Standard functor implementations and comparison objects.
Generic filter iterator wrapper.
Ordered set stored as a sorted contiguous array.
const Key * iterator
Random-access iterator (immutable).
const Key * const_iterator
Random-access const iterator.
const_iterator erase(const_iterator it)
Remove the key at iterator it.
FlatSet(const Compare &cmp, size_t cap=MemArray< Key >::Min_Dim)
Construct an empty set with a specific comparator.
void make_room(const size_t pos)
size_t capacity() const noexcept
Return the capacity of the backing array. O(1).
bool operator==(const FlatSet &s) const
Equality: same size and pairwise equal elements.
const Key & min() const
Smallest key (checked). Alias of get_first().
size_t upper_idx(const Key &k) const
const_iterator upper_bound(const Key &k) const
First element greater than k.
size_t erase(const Key &k)
Remove the key equivalent to k, if present.
FlatSet(std::initializer_list< Key > l, const Compare &cmp=Compare())
Construct from an initializer list.
FlatSet(It first, It last, const Compare &cmp=Compare())
Construct from an iterator range.
size_t lower_idx(const Key &k) const
Key value_type
STL convention: value type.
Key Item_Type
Aleph convention: element type.
const_iterator end() const noexcept
Iterator past the greatest key. O(1).
Key key_type
STL convention: key type.
const_iterator find(const Key &k) const
Find a key.
FlatSet(const FlatSet &)=default
Copy constructor (requires copyable Key).
FlatSet(size_t cap=MemArray< Key >::Min_Dim)
Construct an empty set.
bool match_at(size_t pos, const Key &k) const
std::pair< const_iterator, bool > insert(Key &&k)
Insert k by moving if no equivalent key exists.
void empty() noexcept
Remove all keys (Aleph convention).
Compare key_compare
STL convention: comparator type.
size_t count(const Key &k) const
Count occurrences of a key (0 or 1).
FlatSet(FlatSet &&) noexcept=default
Move constructor. The source is left valid but unspecified.
std::pair< const_iterator, bool > emplace(Args &&...args)
Construct a key in place and insert it.
std::pair< const_iterator, const_iterator > equal_range(const Key &k) const
Range of elements equivalent to k.
const_iterator cend() const noexcept
Const iterator past the greatest key. O(1).
void clear() noexcept
Remove all keys. Alias of empty(). Capacity is kept.
const Key & operator()(size_t i) const noexcept
Positional access without bounds checking.
const Key & max() const
Greatest key (checked). Alias of get_last().
bool traverse(Operation operation) const
Traverse keys in sorted order while operation returns true.
const Key * data() const noexcept
Pointer to the underlying sorted, contiguous storage. O(1).
void reserve(size_t cap)
Reserve capacity for at least cap keys.
const_iterator lower_bound(const Key &k) const
First element not less than k.
bool contains(const Key &k) const
Test membership.
size_t size() const noexcept
Return the number of stored keys. O(1).
size_t size_type
STL convention: size type.
bool is_empty() const noexcept
Return true if the set holds no keys. O(1).
const Key & get_first() const
Smallest key (checked).
const_iterator cbegin() const noexcept
Const iterator to the smallest key. O(1).
const Key & nth(size_t i) const
Positional access to the i-th smallest key (checked).
std::pair< const_iterator, bool > insert(const Key &k)
Insert a copy of k if no equivalent key exists.
Key Key_Type
Aleph convention: key type.
void remove_at(const size_t pos)
const Key & get_last() const
Greatest key (checked).
void swap(FlatSet &s) noexcept(std::is_nothrow_swappable_v< Compare >)
Swap contents with s in O(1).
bool operator!=(const FlatSet &s) const
Inequality: negation of operator==.
const_iterator begin() const noexcept
Iterator to the smallest key. O(1).
Simple, scalable and fast dynamic array.
void reserve(const size_t cap)
Reserves cap cells into the array.
size_t size() const noexcept
Return the number of elements.
void putn(const size_t more)
Reserve more additional logical slots in the array.
void clear() noexcept
Alias for empty().
T * get_ptr() const noexcept
Return the current base of array.
constexpr size_t capacity() const noexcept
The type of element of array.
bool is_empty() const noexcept
Return true is the array is empty.
void empty() noexcept
Empties the container.
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
T & put(const T &item)
Put a copy of item at the end of sequence.
int cmp(const __gmp_expr< T, U > &expr1, const __gmp_expr< V, W > &expr2)
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.
void timsort(T *a, const size_t n, const Compare &cmp=Compare())
Timsort — adaptive, stable, natural merge sort.
and
Check uniqueness with explicit hash + equality functors.
FooMap m(5, fst_unit_pair_hash, snd_unit_pair_hash)
Simple, scalable, contiguous dynamic array.
Comprehensive sorting algorithms and search utilities for Aleph-w.