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);
285 return m_ht.
erase(key, precalculated_hash);
294 class K,
class KE = KeyEqual,
297 return m_ht.
erase(key);
308 class K,
class KE = KeyEqual,
311 return m_ht.
erase(key, precalculated_hash);
327 return m_ht.
count(key, precalculated_hash);
336 class K,
class KE = KeyEqual,
339 return m_ht.
count(key);
350 class K,
class KE = KeyEqual,
353 return m_ht.
count(key, precalculated_hash);
364 return m_ht.
find(key, precalculated_hash);
373 return m_ht.
find(key, precalculated_hash);
382 class K,
class KE = KeyEqual,
385 return m_ht.
find(key);
396 class K,
class KE = KeyEqual,
399 return m_ht.
find(key, precalculated_hash);
406 class K,
class KE = KeyEqual,
409 return m_ht.
find(key);
420 class K,
class KE = KeyEqual,
423 return m_ht.
find(key, precalculated_hash);
433 bool contains(
const Key& key, std::size_t precalculated_hash)
const {
434 return m_ht.
contains(key, precalculated_hash);
443 class K,
class KE = KeyEqual,
457 class K,
class KE = KeyEqual,
459 bool contains(
const K& key, std::size_t precalculated_hash)
const {
460 return m_ht.
contains(key, precalculated_hash);
473 std::size_t precalculated_hash) {
477 std::pair<const_iterator, const_iterator>
equal_range(
const Key& key)
const {
485 const Key& key, std::size_t precalculated_hash)
const {
495 class K,
class KE = KeyEqual,
509 class K,
class KE = KeyEqual,
512 std::size_t precalculated_hash) {
520 class K,
class KE = KeyEqual,
522 std::pair<const_iterator, const_iterator>
equal_range(
const K& key)
const {
530 class K,
class KE = KeyEqual,
533 const K& key, std::size_t precalculated_hash)
const {
588 for (
const auto& element_lhs : lhs) {
589 const auto it_element_rhs = rhs.
find(element_lhs);
590 if (it_element_rhs == rhs.
cend()) {
611 template <
class Serializer>
642 template <
class Deserializer>
644 bool hash_compatible =
false) {
646 set.m_ht.
deserialize(deserializer, hash_compatible);
665 template <
class Key,
class Hash = std::hash<Key>,
666 class KeyEqual = std::equal_to<Key>,
667 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)
void erase_fast(iterator pos)
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)
GLint GLint GLsizei GLint GLenum GLenum type
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)
constexpr auto set(type rhs) -> int
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
void erase_fast(iterator pos)
typename ht::const_iterator const_iterator
robin_set & operator=(std::initializer_list< value_type > ilist)