24 static constexpr int capacity = N;
28 typename array_type::iterator _end;
37 small_map(small_map
const &other)
39 hi_axiom(
this != &other);
41 for (
hilet &other_item : other) {
42 auto &this_item = *(_end++);
43 this_item = other_item;
47 small_map(small_map &&other)
49 hi_axiom(
this != &other);
53 for (
auto &other_item : other) {
54 auto &this_item = *(_end++);
55 swap(this_item, other_item);
60 small_map &operator=(small_map
const &other)
62 hi_return_on_self_assignment(other);
64 for (
hilet &other_item : other) {
65 auto &this_item = *(_end++);
66 this_item = other_item;
71 small_map &operator=(small_map &&other)
73 hi_return_on_self_assignment(other);
75 for (
hilet &other_item : other) {
76 auto &this_item = *(_end++);
79 other._end = other.begin();
85 return _end - items.
begin();
88 decltype(
auto)
begin()
const
92 decltype(
auto)
begin()
96 decltype(
auto)
end()
const
105 std::optional<V> get(K
const &key)
const noexcept
107 for (
auto i =
begin(); i !=
end(); ++i) {
115 V get(K
const &key, V
const &default_value)
const noexcept
117 if (
hilet &value = get(key)) {
120 return default_value;
124 template<
typename KK,
typename VV>
125 bool set(KK &&key, VV &&value)
noexcept
128 for (; i !=
end(); ++i) {
130 i->value = std::forward<VV>(value);
134 if (i != items.
end()) {
136 i->key = std::forward<KK>(key);
137 i->value = std::forward<VV>(value);
144 V increment(K
const &key)
noexcept
146 static_assert(std::is_arithmetic_v<V>,
"Only increment on a artihmatic value");
148 for (; i !=
end(); ++i) {
153 if (i != items.
end()) {
156 return i->value = V{1};