diff --git a/include/pocketpy/namedict.h b/include/pocketpy/namedict.h index 3b180edc..6a75bacc 100644 --- a/include/pocketpy/namedict.h +++ b/include/pocketpy/namedict.h @@ -6,6 +6,100 @@ namespace pkpy{ +template +constexpr T default_invalid_value(){ + if constexpr(std::is_pointer_v) return nullptr; + else if constexpr(std::is_same_v) return -1; + else return Discarded(); +} + +template +struct SmallNameDict{ + using K = StrName; + static_assert(std::is_pod_v); + + static const int kCapacity = 12; + + int _size; + std::pair _items[kCapacity]; + + SmallNameDict(): _size(0) {} + + void set(K key, V val){ + for(int i=0; i(); + } + + bool contains(K key) const { + for(int i=0; i + void apply(Func func) const { + for(int i=0; i