diff options
author | Anton Samokhvalov <pg83@yandex.ru> | 2022-02-10 16:45:15 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:15 +0300 |
commit | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch) | |
tree | da2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /util/generic/hash_set.h | |
parent | 778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff) | |
download | ydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz |
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'util/generic/hash_set.h')
-rw-r--r-- | util/generic/hash_set.h | 486 |
1 files changed, 243 insertions, 243 deletions
diff --git a/util/generic/hash_set.h b/util/generic/hash_set.h index e8088cf23b..68f1880031 100644 --- a/util/generic/hash_set.h +++ b/util/generic/hash_set.h @@ -1,8 +1,8 @@ -#pragma once - +#pragma once + #include "fwd.h" #include "hash.h" - + #include <initializer_list> #include <utility> @@ -12,7 +12,7 @@ template <class Value, class HashFcn, class EqualKey, class Alloc> class THashSet { private: using ht = THashTable<Value, Value, HashFcn, ::TIdentity, EqualKey, Alloc>; - ht rep; + ht rep; using mutable_iterator = typename ht::iterator; @@ -37,31 +37,31 @@ public: hasher hash_function() const { return rep.hash_function(); - } - key_equal key_eq() const { - return rep.key_eq(); - } + } + key_equal key_eq() const { + return rep.key_eq(); + } public: THashSet() { - } - template <class TT> + } + template <class TT> explicit THashSet(TT* allocParam, size_type n = 0) : rep(n, hasher(), key_equal(), allocParam) - { - } + { + } explicit THashSet(size_type n) - : rep(n, hasher(), key_equal()) - { - } + : rep(n, hasher(), key_equal()) + { + } THashSet(size_type n, const hasher& hf) - : rep(n, hf, key_equal()) - { - } + : rep(n, hf, key_equal()) + { + } THashSet(size_type n, const hasher& hf, const key_equal& eql) - : rep(n, hf, eql) - { - } + : rep(n, hf, eql) + { + } THashSet(std::initializer_list<value_type> list) : rep(list.size(), hasher(), key_equal()) @@ -84,67 +84,67 @@ public: rep.insert_unique(list.begin(), list.end()); } - template <class InputIterator> + template <class InputIterator> THashSet(InputIterator f, InputIterator l) - : rep(0, hasher(), key_equal()) - { - rep.insert_unique(f, l); - } - template <class InputIterator> + : rep(0, hasher(), key_equal()) + { + rep.insert_unique(f, l); + } + template <class InputIterator> THashSet(InputIterator f, InputIterator l, size_type n) - : rep(n, hasher(), key_equal()) - { - rep.insert_unique(f, l); - } - template <class InputIterator> + : rep(n, hasher(), key_equal()) + { + rep.insert_unique(f, l); + } + template <class InputIterator> THashSet(InputIterator f, InputIterator l, size_type n, - const hasher& hf) - : rep(n, hf, key_equal()) - { - rep.insert_unique(f, l); - } - template <class InputIterator> + const hasher& hf) + : rep(n, hf, key_equal()) + { + rep.insert_unique(f, l); + } + template <class InputIterator> THashSet(InputIterator f, InputIterator l, size_type n, - const hasher& hf, const key_equal& eql) - : rep(n, hf, eql) - { - rep.insert_unique(f, l); - } + const hasher& hf, const key_equal& eql) + : rep(n, hf, eql) + { + rep.insert_unique(f, l); + } // THashSet has implicit copy/move constructors and copy-/move-assignment operators // because its implementation is backed by THashTable. - // See hash_ut.cpp + // See hash_ut.cpp public: - size_type size() const { - return rep.size(); - } - size_type max_size() const { - return rep.max_size(); - } - - Y_PURE_FUNCTION bool empty() const { - return rep.empty(); - } - explicit operator bool() const noexcept { - return !empty(); - } + size_type size() const { + return rep.size(); + } + size_type max_size() const { + return rep.max_size(); + } + + Y_PURE_FUNCTION bool empty() const { + return rep.empty(); + } + explicit operator bool() const noexcept { + return !empty(); + } void swap(THashSet& hs) { - rep.swap(hs.rep); - } - - iterator begin() const { - return rep.begin(); - } - iterator end() const { - return rep.end(); - } - iterator cbegin() const { - return rep.begin(); - } - iterator cend() const { - return rep.end(); - } + rep.swap(hs.rep); + } + + iterator begin() const { + return rep.begin(); + } + iterator end() const { + return rep.end(); + } + iterator cbegin() const { + return rep.begin(); + } + iterator cend() const { + return rep.end(); + } public: void insert(std::initializer_list<value_type> ilist) { @@ -160,7 +160,7 @@ public: std::pair<mutable_iterator, bool> p = rep.insert_unique(obj); return std::pair<iterator, bool>(p.first, p.second); } - template <typename... Args> + template <typename... Args> std::pair<iterator, bool> emplace(Args&&... args) { std::pair<mutable_iterator, bool> p = rep.emplace_unique(std::forward<Args>(args)...); return std::pair<iterator, bool>(p.first, p.second); @@ -174,32 +174,32 @@ public: std::pair<iterator, bool> insert_noresize(const value_type& obj) { std::pair<mutable_iterator, bool> p = rep.insert_unique_noresize(obj); return std::pair<iterator, bool>(p.first, p.second); - } - template <typename... Args> + } + template <typename... Args> std::pair<iterator, bool> emplace_noresize(Args&&... args) { std::pair<mutable_iterator, bool> p = rep.emplace_unique_noresize(std::forward<Args>(args)...); return std::pair<iterator, bool>(p.first, p.second); } - template <class TheObj> - iterator insert_direct(const TheObj& obj, const insert_ctx& ins) { - return rep.insert_direct(obj, ins); - } + template <class TheObj> + iterator insert_direct(const TheObj& obj, const insert_ctx& ins) { + return rep.insert_direct(obj, ins); + } template <typename... Args> iterator emplace_direct(const insert_ctx& ins, Args&&... args) { return rep.emplace_direct(ins, std::forward<Args>(args)...); } - template <class TheKey> + template <class TheKey> const_iterator find(const TheKey& key) const { - return rep.find(key); - } - template <class TheKey> - iterator find(const TheKey& key, insert_ctx& ins) { - return rep.find_i(key, ins); - } - - template <class TheKey> + return rep.find(key); + } + template <class TheKey> + iterator find(const TheKey& key, insert_ctx& ins) { + return rep.find_i(key, ins); + } + + template <class TheKey> bool contains(const TheKey& key) const { return rep.find(key) != rep.end(); } @@ -208,56 +208,56 @@ public: return rep.find_i(key, ins) != rep.end(); } - template <class TKey> - size_type count(const TKey& key) const { - return rep.count(key); - } + template <class TKey> + size_type count(const TKey& key) const { + return rep.count(key); + } - template <class TKey> + template <class TKey> std::pair<iterator, iterator> equal_range(const TKey& key) const { - return rep.equal_range(key); - } - - size_type erase(const key_type& key) { - return rep.erase(key); - } - void erase(iterator it) { - rep.erase(it); - } - void erase(iterator f, iterator l) { - rep.erase(f, l); - } - void clear() { - rep.clear(); - } - void clear(size_t downsize_hint) { - rep.clear(downsize_hint); - } - void basic_clear() { - rep.basic_clear(); - } + return rep.equal_range(key); + } + + size_type erase(const key_type& key) { + return rep.erase(key); + } + void erase(iterator it) { + rep.erase(it); + } + void erase(iterator f, iterator l) { + rep.erase(f, l); + } + void clear() { + rep.clear(); + } + void clear(size_t downsize_hint) { + rep.clear(downsize_hint); + } + void basic_clear() { + rep.basic_clear(); + } void release_nodes() { rep.release_nodes(); } - template <class KeySaver> + template <class KeySaver> int save_for_st(IOutputStream* stream, KeySaver& ks) const { return rep.template save_for_st<KeySaver>(stream, ks); - } + } public: void reserve(size_type hint) { rep.reserve(hint); - } - size_type bucket_count() const { - return rep.bucket_count(); - } + } + size_type bucket_count() const { + return rep.bucket_count(); + } size_type bucket_size(size_type n) const { return rep.bucket_size(n); - } - node_allocator_type& GetNodeAllocator() { - return rep.GetNodeAllocator(); - } + } + node_allocator_type& GetNodeAllocator() { + return rep.GetNodeAllocator(); + } }; template <class Value, class HashFcn, class EqualKey, class Alloc> @@ -282,7 +282,7 @@ template <class Value, class HashFcn, class EqualKey, class Alloc> class THashMultiSet { private: using ht = THashTable<Value, Value, HashFcn, ::TIdentity, EqualKey, Alloc>; - ht rep; + ht rep; public: using key_type = typename ht::key_type; @@ -304,55 +304,55 @@ public: hasher hash_function() const { return rep.hash_function(); - } - key_equal key_eq() const { - return rep.key_eq(); - } + } + key_equal key_eq() const { + return rep.key_eq(); + } public: THashMultiSet() - : rep(0, hasher(), key_equal()) - { - } + : rep(0, hasher(), key_equal()) + { + } explicit THashMultiSet(size_type n) - : rep(n, hasher(), key_equal()) - { - } + : rep(n, hasher(), key_equal()) + { + } THashMultiSet(size_type n, const hasher& hf) - : rep(n, hf, key_equal()) - { - } + : rep(n, hf, key_equal()) + { + } THashMultiSet(size_type n, const hasher& hf, const key_equal& eql) - : rep(n, hf, eql) - { - } + : rep(n, hf, eql) + { + } - template <class InputIterator> + template <class InputIterator> THashMultiSet(InputIterator f, InputIterator l) - : rep(0, hasher(), key_equal()) - { - rep.insert_equal(f, l); - } - template <class InputIterator> + : rep(0, hasher(), key_equal()) + { + rep.insert_equal(f, l); + } + template <class InputIterator> THashMultiSet(InputIterator f, InputIterator l, size_type n) - : rep(n, hasher(), key_equal()) - { - rep.insert_equal(f, l); - } - template <class InputIterator> + : rep(n, hasher(), key_equal()) + { + rep.insert_equal(f, l); + } + template <class InputIterator> THashMultiSet(InputIterator f, InputIterator l, size_type n, - const hasher& hf) - : rep(n, hf, key_equal()) - { - rep.insert_equal(f, l); - } - template <class InputIterator> + const hasher& hf) + : rep(n, hf, key_equal()) + { + rep.insert_equal(f, l); + } + template <class InputIterator> THashMultiSet(InputIterator f, InputIterator l, size_type n, - const hasher& hf, const key_equal& eql) - : rep(n, hf, eql) - { - rep.insert_equal(f, l); - } + const hasher& hf, const key_equal& eql) + : rep(n, hf, eql) + { + rep.insert_equal(f, l); + } THashMultiSet(std::initializer_list<value_type> list) : rep(list.size(), hasher(), key_equal()) @@ -362,88 +362,88 @@ public: // THashMultiSet has implicit copy/move constructors and copy-/move-assignment operators // because its implementation is backed by THashTable. - // See hash_ut.cpp + // See hash_ut.cpp public: - size_type size() const { - return rep.size(); - } - size_type max_size() const { - return rep.max_size(); - } - - Y_PURE_FUNCTION bool empty() const { - return rep.empty(); - } - explicit operator bool() const noexcept { - return !empty(); - } + size_type size() const { + return rep.size(); + } + size_type max_size() const { + return rep.max_size(); + } + + Y_PURE_FUNCTION bool empty() const { + return rep.empty(); + } + explicit operator bool() const noexcept { + return !empty(); + } void swap(THashMultiSet& hs) { - rep.swap(hs.rep); - } - - iterator begin() const { - return rep.begin(); - } - iterator end() const { - return rep.end(); - } - iterator cbegin() const { - return rep.begin(); - } - iterator cend() const { - return rep.end(); - } + rep.swap(hs.rep); + } + + iterator begin() const { + return rep.begin(); + } + iterator end() const { + return rep.end(); + } + iterator cbegin() const { + return rep.begin(); + } + iterator cend() const { + return rep.end(); + } public: - iterator insert(const value_type& obj) { - return rep.insert_equal(obj); - } + iterator insert(const value_type& obj) { + return rep.insert_equal(obj); + } template <typename... Args> iterator emplace(Args&&... args) { return rep.emplace_equal(std::forward<Args>(args)...); } - template <class InputIterator> - void insert(InputIterator f, InputIterator l) { - rep.insert_equal(f, l); - } - iterator insert_noresize(const value_type& obj) { - return rep.insert_equal_noresize(obj); - } - - template <class TKey> - iterator find(const TKey& key) const { - return rep.find(key); - } - - template <class TKey> - size_type count(const TKey& key) const { - return rep.count(key); - } - - template <class TKey> + template <class InputIterator> + void insert(InputIterator f, InputIterator l) { + rep.insert_equal(f, l); + } + iterator insert_noresize(const value_type& obj) { + return rep.insert_equal_noresize(obj); + } + + template <class TKey> + iterator find(const TKey& key) const { + return rep.find(key); + } + + template <class TKey> + size_type count(const TKey& key) const { + return rep.count(key); + } + + template <class TKey> std::pair<iterator, iterator> equal_range(const TKey& key) const { - return rep.equal_range(key); - } - - size_type erase(const key_type& key) { - return rep.erase(key); - } - void erase(iterator it) { - rep.erase(it); - } - void erase(iterator f, iterator l) { - rep.erase(f, l); - } - void clear() { - rep.clear(); - } - void clear(size_t downsize_hint) { - rep.clear(downsize_hint); - } - void basic_clear() { - rep.basic_clear(); - } + return rep.equal_range(key); + } + + size_type erase(const key_type& key) { + return rep.erase(key); + } + void erase(iterator it) { + rep.erase(it); + } + void erase(iterator f, iterator l) { + rep.erase(f, l); + } + void clear() { + rep.clear(); + } + void clear(size_t downsize_hint) { + rep.clear(downsize_hint); + } + void basic_clear() { + rep.basic_clear(); + } void release_nodes() { rep.release_nodes(); } @@ -451,16 +451,16 @@ public: public: void reserve(size_type hint) { rep.reserve(hint); - } - size_type bucket_count() const { - return rep.bucket_count(); - } + } + size_type bucket_count() const { + return rep.bucket_count(); + } size_type bucket_size(size_type n) const { return rep.bucket_size(n); - } - node_allocator_type& GetNodeAllocator() { - return rep.GetNodeAllocator(); - } + } + node_allocator_type& GetNodeAllocator() { + return rep.GetNodeAllocator(); + } }; template <class Val, class HashFcn, class EqualKey, class Alloc> |