diff options
author | Devtools Arcadia <arcadia-devtools@yandex-team.ru> | 2022-02-07 18:08:42 +0300 |
---|---|---|
committer | Devtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net> | 2022-02-07 18:08:42 +0300 |
commit | 1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch) | |
tree | e26c9fed0de5d9873cce7e00bc214573dc2195b7 /util/generic/map.h | |
download | ydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz |
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'util/generic/map.h')
-rw-r--r-- | util/generic/map.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/util/generic/map.h b/util/generic/map.h new file mode 100644 index 0000000000..b5001b56c0 --- /dev/null +++ b/util/generic/map.h @@ -0,0 +1,44 @@ +#pragma once + +#include "fwd.h" +#include "mapfindptr.h" + +#include <util/str_stl.h> +#include <util/memory/alloc.h> + +#include <utility> +#include <initializer_list> +#include <map> +#include <memory> + +template <class K, class V, class Less, class A> +class TMap: public std::map<K, V, Less, TReboundAllocator<A, std::pair<const K, V>>>, public TMapOps<TMap<K, V, Less, A>> { + using TBase = std::map<K, V, Less, TReboundAllocator<A, std::pair<const K, V>>>; + +public: + using TBase::TBase; + + inline explicit operator bool() const noexcept { + return !this->empty(); + } + + inline bool contains(const K& key) const { + return this->find(key) != this->end(); + } +}; + +template <class K, class V, class Less, class A> +class TMultiMap: public std::multimap<K, V, Less, TReboundAllocator<A, std::pair<const K, V>>> { + using TBase = std::multimap<K, V, Less, TReboundAllocator<A, std::pair<const K, V>>>; + +public: + using TBase::TBase; + + inline explicit operator bool() const noexcept { + return !this->empty(); + } + + inline bool contains(const K& key) const { + return this->find(key) != this->end(); + } +}; |