7#include "utility/module.hpp"
13namespace hi::inline
v1 {
15template<
typename K,
typename V,
int N>
24 static constexpr int capacity = N;
28 typename array_type::iterator _end;
29 array_type items = {};
37 small_map(small_map
const &other)
41 for (hilet &other_item : other) {
42 auto &this_item = *(_end++);
43 this_item = other_item;
47 small_map(small_map &&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++);
83 std::size_t size()
const
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) {
134 if (i != items.
end()) {
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};
#define hi_axiom(expression,...)
Specify an axiom; an expression that is true.
Definition assert.hpp:253
#define hilet
Invariant should be the default for variables.
Definition utility.hpp:23
@ other
The gui_event does not have associated data.
Definition gui_event_variant.hpp:21
DOXYGEN BUG.
Definition algorithm.hpp:13
Definition small_map.hpp:16
Definition small_map.hpp:20