7#include "../utility/utility.hpp"
8#include "../macros.hpp"
18template<
typename Key,
typename Value>
27 item &operator += (Value
const &value)
noexcept
37 [[nodiscard]]
friend bool can_be_merged(item
const &lhs, item
const &rhs)
noexcept
39 return lhs.last == rhs.first && lhs.values == rhs.values;
47 auto find(Key
const &key)
noexcept
64 void insert(Key
const &first, Key
const &last, Value &&value)
noexcept
66 hi_assert(last > first);
69 auto first_ = find(first);
70 auto last_ = find(last);
74 hi_axiom(first_ != items.
end());
75 if (first_->first != first) {
77 hilet tmp_last = first_->last;
80 first_ = items.
emplace(first_ + 1, first, tmp_last, first_->values);
81 last_ = first_ + delta;
84 hi_axiom(last_ != items.
end());
85 if (last_->last != last) {
87 hilet tmp_first = last_->first;
90 last_ = items.
emplace(last_, tmp_first, last, first_->values);
91 first_ = last_ - delta;
94 hi_axiom(last_ != items.
end());
96 for (
auto i = first_; i != last_; ++i) {
107 [](hilet &lhs, hilet &rhs) {
112 auto p = items.
begin();
113 values_set.insert(p->values);
114 for (
auto i = p + 1; i != items.
end(); p = i++) {
116 hilet[deduplicated_values, dummy] = values_set.insert(i->values);
117 i->values = *deduplicated_values;
119 if (can_be_merged(*p, *i)) {
129 values
const &operator[](Key
const &key)
const noexcept
131 return *((find(key))->values);
DOXYGEN BUG.
Definition algorithm.hpp:16
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:377
Definition range_map.hpp:19
void insert(Key const &first, Key const &last, Value &&value) noexcept
Insert half open range of keys.
Definition range_map.hpp:64
void optimize() noexcept
Optimize range_map for improved lookup performance and reduced memory footprint.
Definition range_map.hpp:103
T emplace_back(T... args)
T shrink_to_fit(T... args)