27 constexpr static int capacity = N;
31 typename array_type::iterator _end;
40 small_map(small_map
const &other)
42 hi_axiom(
this != &other);
44 for (hilet &other_item : other) {
45 auto &this_item = *(_end++);
46 this_item = other_item;
50 small_map(small_map &&other)
52 hi_axiom(
this != &other);
56 for (
auto &other_item :
other) {
57 auto &this_item = *(_end++);
58 swap(this_item, other_item);
63 small_map &operator=(small_map
const &other)
65 hi_return_on_self_assignment(other);
67 for (hilet &other_item :
other) {
68 auto &this_item = *(_end++);
69 this_item = other_item;
74 small_map &operator=(small_map &&other)
76 hi_return_on_self_assignment(other);
78 for (hilet &other_item :
other) {
79 auto &this_item = *(_end++);
88 return _end - items.
begin();
91 decltype(
auto)
begin()
const
95 decltype(
auto)
begin()
99 decltype(
auto)
end()
const
108 std::optional<V> get(K
const &key)
const noexcept
110 for (
auto i =
begin(); i !=
end(); ++i) {
118 V get(K
const &key, V
const &default_value)
const noexcept
120 if (hilet &value = get(key)) {
123 return default_value;
127 template<
typename KK,
typename VV>
128 bool set(KK &&key, VV &&value)
noexcept
131 for (; i !=
end(); ++i) {
133 i->value = std::forward<VV>(value);
137 if (i != items.
end()) {
139 i->key = std::forward<KK>(key);
140 i->value = std::forward<VV>(value);
147 V increment(K
const &key)
noexcept
149 static_assert(std::is_arithmetic_v<V>,
"Only increment on a artihmatic value");
151 for (; i !=
end(); ++i) {
156 if (i != items.
end()) {
159 return i->value = V{1};