24 #ifndef PXR_TSL_ROBIN_SET_H
25 #define PXR_TSL_ROBIN_SET_H
29 #include <initializer_list>
31 #include <type_traits>
91 template <
class Key,
class Hash = std::hash<Key>,
92 class KeyEqual = std::equal_to<Key>,
93 class Allocator = std::allocator<Key>,
bool StoreHash = false,
94 class GrowthPolicy = pxr_tsl::rh::power_of_two_growth_policy<2>>
104 const key_type& operator()(
const Key& key)
const noexcept {
return key; }
106 key_type& operator()(Key& key) noexcept {
return key; }
110 Allocator, StoreHash, GrowthPolicy>;
133 const KeyEqual&
equal = KeyEqual(),
134 const Allocator& alloc = Allocator())
135 : m_ht(bucket_count, hash,
equal, alloc) {}
141 :
robin_set(bucket_count, hash, KeyEqual(), alloc) {}
144 :
robin_set(
ht::DEFAULT_INIT_BUCKETS_SIZE, alloc) {}
146 template <
class InputIt>
149 const Hash& hash =
Hash(),
const KeyEqual&
equal = KeyEqual(),
150 const Allocator& alloc = Allocator())
155 template <
class InputIt>
157 const Allocator& alloc)
158 :
robin_set(first, last, bucket_count,
Hash(), KeyEqual(), alloc) {}
160 template <
class InputIt>
162 const Hash& hash,
const Allocator& alloc)
163 :
robin_set(first, last, bucket_count, hash, KeyEqual(), alloc) {}
167 const Hash& hash =
Hash(),
const KeyEqual&
equal = KeyEqual(),
168 const Allocator& alloc = Allocator())
172 const Allocator& alloc)
177 const Hash& hash,
const Allocator& alloc)
185 m_ht.
insert(ilist.begin(), ilist.end());
216 return m_ht.
insert(value);
231 template <
class InputIt>
232 void insert(InputIt first, InputIt last) {
236 void insert(std::initializer_list<value_type> ilist) {
237 m_ht.
insert(ilist.begin(), ilist.end());
247 template <
class... Args>
259 template <
class... Args>
267 return m_ht.
erase(first, last);
277 return m_ht.
erase(key, precalculated_hash);
286 class K,
class KE = KeyEqual,
289 return m_ht.
erase(key);
300 class K,
class KE = KeyEqual,
303 return m_ht.
erase(key, precalculated_hash);
319 return m_ht.
count(key, precalculated_hash);
328 class K,
class KE = KeyEqual,
331 return m_ht.
count(key);
342 class K,
class KE = KeyEqual,
345 return m_ht.
count(key, precalculated_hash);
356 return m_ht.
find(key, precalculated_hash);
365 return m_ht.
find(key, precalculated_hash);
374 class K,
class KE = KeyEqual,
377 return m_ht.
find(key);
388 class K,
class KE = KeyEqual,
391 return m_ht.
find(key, precalculated_hash);
398 class K,
class KE = KeyEqual,
401 return m_ht.
find(key);
412 class K,
class KE = KeyEqual,
415 return m_ht.
find(key, precalculated_hash);
425 bool contains(
const Key& key, std::size_t precalculated_hash)
const {
426 return m_ht.
contains(key, precalculated_hash);
435 class K,
class KE = KeyEqual,
449 class K,
class KE = KeyEqual,
451 bool contains(
const K& key, std::size_t precalculated_hash)
const {
452 return m_ht.
contains(key, precalculated_hash);
465 std::size_t precalculated_hash) {
469 std::pair<const_iterator, const_iterator>
equal_range(
const Key& key)
const {
477 const Key& key, std::size_t precalculated_hash)
const {
487 class K,
class KE = KeyEqual,
501 class K,
class KE = KeyEqual,
504 std::size_t precalculated_hash) {
512 class K,
class KE = KeyEqual,
514 std::pair<const_iterator, const_iterator>
equal_range(
const K& key)
const {
522 class K,
class KE = KeyEqual,
525 const K& key, std::size_t precalculated_hash)
const {
580 for (
const auto& element_lhs : lhs) {
581 const auto it_element_rhs = rhs.
find(element_lhs);
582 if (it_element_rhs == rhs.
cend()) {
603 template <
class Serializer>
634 template <
class Deserializer>
636 bool hash_compatible =
false) {
638 set.m_ht.
deserialize(deserializer, hash_compatible);
657 template <
class Key,
class Hash = std::hash<Key>,
658 class KeyEqual = std::equal_to<Key>,
659 class Allocator = std::allocator<Key>,
bool StoreHash = false>
iterator erase(const_iterator pos)
robin_set(InputIt first, InputIt last, size_type bucket_count, const Hash &hash, const Allocator &alloc)
iterator erase(iterator pos)
typename ht::allocator_type allocator_type
iterator find(const Key &key, std::size_t precalculated_hash)
size_type bucket_count() const
iterator emplace_hint(const_iterator hint, Args &&...args)
float load_factor() const
typename KeySelect::key_type key_type
void reserve(size_type count_)
size_type max_bucket_count() const
float min_load_factor() const
void deserialize(Deserializer &deserializer, bool hash_compatible)
STATIC_INLINE size_t Hash(const char *s, size_t len)
iterator mutable_iterator(const_iterator pos)
void max_load_factor(float ml)
robin_set< Key, Hash, KeyEqual, Allocator, StoreHash, pxr_tsl::rh::prime_growth_policy > robin_pg_set
typename ht::iterator iterator
GLsizei const GLfloat * value
float load_factor() const
hasher hash_function() const
typename ht::key_equal key_equal
const_iterator find(const Key &key) const
bool contains(const Key &key, std::size_t precalculated_hash) const
std::pair< iterator, iterator > equal_range(const Key &key)
iterator emplace_hint(const_iterator hint, Args &&...args)
void swap(robin_hash &other)
iterator insert(const_iterator hint, value_type &&value)
std::pair< iterator, bool > insert(value_type &&value)
void serialize(Serializer &serializer) const
const_iterator find(const K &key) const
IMATH_HOSTDEVICE constexpr bool equal(T1 a, T2 b, T3 t) IMATH_NOEXCEPT
std::pair< iterator, iterator > equal_range(const K &key)
std::pair< iterator, iterator > equal_range(const Key &key, std::size_t precalculated_hash)
bool contains(const K &key) const
bool contains(const Key &key) const
void rehash(size_type count_)
friend bool operator==(const robin_set &lhs, const robin_set &rhs)
size_type erase(const key_type &key, std::size_t precalculated_hash)
typename ht::const_reference const_reference
std::pair< iterator, bool > emplace(Args &&...args)
robin_set(std::initializer_list< value_type > init, size_type bucket_count, const Allocator &alloc)
void insert(InputIt first, InputIt last)
std::pair< iterator, iterator > equal_range(const K &key, std::size_t precalculated_hash)
size_type count(const Key &key) const
std::pair< iterator, bool > emplace(Args &&...args)
robin_set(InputIt first, InputIt last, size_type bucket_count, const Allocator &alloc)
size_type count(const Key &key, std::size_t precalculated_hash) const
std::pair< const_iterator, const_iterator > equal_range(const K &key) const
iterator insert_hint(const_iterator hint, P &&value)
size_type size() const noexcept
float max_load_factor() const
const_iterator cbegin() const noexcept
size_type count(const K &key) const
const_iterator find(const Key &key, std::size_t precalculated_hash) const
const_iterator cend() const noexcept
void rehash(size_type count_)
robin_set(std::initializer_list< value_type > init, size_type bucket_count=ht::DEFAULT_INIT_BUCKETS_SIZE, const Hash &hash=Hash(), const KeyEqual &equal=KeyEqual(), const Allocator &alloc=Allocator())
std::ptrdiff_t difference_type
robin_set(const Allocator &alloc)
typename ht::difference_type difference_type
size_type count(const K &key, std::size_t precalculated_hash) const
const_iterator begin() const noexcept
iterator find(const K &key)
robin_iterator< true > const_iterator
robin_set(InputIt first, InputIt last, size_type bucket_count=ht::DEFAULT_INIT_BUCKETS_SIZE, const Hash &hash=Hash(), const KeyEqual &equal=KeyEqual(), const Allocator &alloc=Allocator())
typename ht::const_pointer const_pointer
void insert(std::initializer_list< value_type > ilist)
friend bool operator!=(const robin_set &lhs, const robin_set &rhs)
static robin_set deserialize(Deserializer &deserializer, bool hash_compatible=false)
const_iterator find(const K &key, std::size_t precalculated_hash) const
friend void swap(robin_set &lhs, robin_set &rhs)
size_type erase(const K &key)
bool empty() const noexcept
std::pair< iterator, bool > insert(P &&value)
iterator begin() noexcept
bool empty() const noexcept
typename ht::pointer pointer
size_type max_size() const noexcept
robin_set(size_type bucket_count, const Hash &hash=Hash(), const KeyEqual &equal=KeyEqual(), const Allocator &alloc=Allocator())
iterator erase(const_iterator first, const_iterator last)
typename ht::reference reference
void min_load_factor(float ml)
typename ht::value_type value_type
size_type erase(const K &key, std::size_t precalculated_hash)
const value_type & const_reference
const_iterator cbegin() const noexcept
const value_type * const_pointer
std::pair< const_iterator, const_iterator > equal_range(const Key &key, std::size_t precalculated_hash) const
size_type erase(const key_type &key)
std::pair< iterator, bool > insert(const value_type &value)
float min_load_factor() const
iterator begin() noexcept
__hostdev__ uint64_t last(uint32_t i) const
iterator mutable_iterator(const_iterator pos)
std::pair< iterator, iterator > equal_range(const K &key)
bool contains(const K &key, std::size_t precalculated_hash) const
size_type max_size() const noexcept
robin_set(std::initializer_list< value_type > init, size_type bucket_count, const Hash &hash, const Allocator &alloc)
const_iterator cend() const noexcept
size_type max_bucket_count() const
hasher hash_function() const
robin_iterator< false > iterator
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
std::pair< const_iterator, const_iterator > equal_range(const K &key, std::size_t precalculated_hash) const
const_iterator end() const noexcept
#define PXR_NAMESPACE_CLOSE_SCOPE
iterator insert(const_iterator hint, const value_type &value)
**If you just want to fire and args
size_type size() const noexcept
robin_set(size_type bucket_count, const Allocator &alloc)
void serialize(Serializer &serializer) const
iterator find(const K &key)
size_type count(const K &key) const
robin_set(size_type bucket_count, const Hash &hash, const Allocator &alloc)
void swap(robin_set &other)
allocator_type get_allocator() const
bool contains(const K &key) const
static const size_type DEFAULT_INIT_BUCKETS_SIZE
iterator find(const Key &key)
allocator_type get_allocator() const
float max_load_factor() const
iterator find(const K &key, std::size_t precalculated_hash)
typename ht::hasher hasher
std::pair< const_iterator, const_iterator > equal_range(const Key &key) const
iterator erase(iterator pos)
typename ht::key_type key_type
size_type bucket_count() const
void reserve(size_type count_)
typename ht::size_type size_type
typename ht::const_iterator const_iterator
robin_set & operator=(std::initializer_list< value_type > ilist)