14namespace hi::inline
v1 {
16template<
typename Key,
typename Value>
25 item &operation += (Value
const &value)
noexcept
35 [[nodiscard]]
friend bool can_be_merged(item
const &lhs, item
const &rhs)
noexcept
37 return lhs.last == rhs.first && lhs.values == rhs.values;
45 auto find(Key
const &key)
noexcept
62 void insert(Key
const &first, Key
const &last, Value &&value)
noexcept
67 auto first_ = find(first);
68 auto last_ = find(last);
73 if (first_->first != first) {
75 hilet tmp_last = first_->last;
78 first_ = items.
emplace(first_ + 1, first, tmp_last, first_->values);
79 last_ = first_ + delta;
83 if (last_->last != last) {
85 hilet tmp_first = last_->first;
88 last_ = items.
emplace(last_, tmp_first, last, first_->values);
89 first_ = last_ - delta;
94 for (
auto i = first_; i != last_; ++i) {
110 auto p = items.
begin();
111 values_set.insert(p->values);
112 for (
auto i = p + 1; i != items.
end(); p = i++) {
114 hilet[deduplicated_values, dummy] = values_set.insert(i->values);
115 i->values = *deduplicated_values;
117 if (can_be_merged(*p, *i)) {
127 values
const &operator[](Key
const &key)
const noexcept
129 return *((find(key))->values);
Utilities to assert and bound check.
#define hi_axiom(expression)
Specify an axiom; an expression that is true.
Definition assert.hpp:133
#define hi_assert(expression)
Assert if expression is true.
Definition assert.hpp:86
Utilities used by the HikoGUI library itself.
#define hilet
Invariant should be the default for variables.
Definition utility.hpp:23
DOXYGEN BUG.
Definition algorithm.hpp:15
Definition range_map.hpp:17
void insert(Key const &first, Key const &last, Value &&value) noexcept
Insert half open range of keys.
Definition range_map.hpp:62
void optimize() noexcept
Optimize range_map for improved lookup performance and reduced memory footprint.
Definition range_map.hpp:101
T emplace_back(T... args)
T shrink_to_fit(T... args)