HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
robin_set.h
Go to the documentation of this file.
1 /**
2  * MIT License
3  *
4  * Copyright (c) 2017 Thibaut Goetghebuer-Planchon <tessil@gmx.com>
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24 #ifndef PXR_TSL_ROBIN_SET_H
25 #define PXR_TSL_ROBIN_SET_H
26 
27 #include <cstddef>
28 #include <functional>
29 #include <initializer_list>
30 #include <memory>
31 #include <type_traits>
32 #include <utility>
33 
34 #include "robin_hash.h"
35 
36 // Pixar modification, modify namespace for isolation.
37 #include "pxr/pxr.h"
38 
40 
41 namespace pxr_tsl {
42 
43 /**
44  * Implementation of a hash set using open-addressing and the robin hood hashing
45  * algorithm with backward shift deletion.
46  *
47  * For operations modifying the hash set (insert, erase, rehash, ...), the
48  * strong exception guarantee is only guaranteed when the expression
49  * `std::is_nothrow_swappable<Key>::value &&
50  * std::is_nothrow_move_constructible<Key>::value` is true, otherwise if an
51  * exception is thrown during the swap or the move, the hash set may end up in a
52  * undefined state. Per the standard a `Key` with a noexcept copy constructor
53  * and no move constructor also satisfies the
54  * `std::is_nothrow_move_constructible<Key>::value` criterion (and will thus
55  * guarantee the strong exception for the set).
56  *
57  * When `StoreHash` is true, 32 bits of the hash are stored alongside the
58  * values. It can improve the performance during lookups if the `KeyEqual`
59  * function takes time (or engenders a cache-miss for example) as we then
60  * compare the stored hashes before comparing the keys. When
61  * `pxr_tsl::rh::power_of_two_growth_policy` is used as `GrowthPolicy`, it may also
62  * speed-up the rehash process as we can avoid to recalculate the hash. When it
63  * is detected that storing the hash will not incur any memory penalty due to
64  * alignment (i.e. `sizeof(pxr_tsl::detail_robin_hash::bucket_entry<ValueType,
65  * true>) == sizeof(pxr_tsl::detail_robin_hash::bucket_entry<ValueType, false>)`)
66  * and `pxr_tsl::rh::power_of_two_growth_policy` is used, the hash will be stored
67  * even if `StoreHash` is false so that we can speed-up the rehash (but it will
68  * not be used on lookups unless `StoreHash` is true).
69  *
70  * `GrowthPolicy` defines how the set grows and consequently how a hash value is
71  * mapped to a bucket. By default the set uses
72  * `pxr_tsl::rh::power_of_two_growth_policy`. This policy keeps the number of
73  * buckets to a power of two and uses a mask to set the hash to a bucket instead
74  * of the slow modulo. Other growth policies are available and you may define
75  * your own growth policy, check `pxr_tsl::rh::power_of_two_growth_policy` for the
76  * interface.
77  *
78  * `Key` must be swappable.
79  *
80  * `Key` must be copy and/or move constructible.
81  *
82  * If the destructor of `Key` throws an exception, the behaviour of the class is
83  * undefined.
84  *
85  * Iterators invalidation:
86  * - clear, operator=, reserve, rehash: always invalidate the iterators.
87  * - insert, emplace, emplace_hint, operator[]: if there is an effective
88  * insert, invalidate the iterators.
89  * - erase: always invalidate the iterators.
90  */
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>>
95 class robin_set {
96  private:
97  template <typename U>
99 
100  class KeySelect {
101  public:
102  using key_type = Key;
103 
104  const key_type& operator()(const Key& key) const noexcept { return key; }
105 
106  key_type& operator()(Key& key) noexcept { return key; }
107  };
108 
109  using ht = detail_robin_hash::robin_hash<Key, KeySelect, void, Hash, KeyEqual,
110  Allocator, StoreHash, GrowthPolicy>;
111 
112  public:
113  using key_type = typename ht::key_type;
114  using value_type = typename ht::value_type;
115  using size_type = typename ht::size_type;
117  using hasher = typename ht::hasher;
118  using key_equal = typename ht::key_equal;
120  using reference = typename ht::reference;
122  using pointer = typename ht::pointer;
124  using iterator = typename ht::iterator;
126 
127  /*
128  * Constructors
129  */
130  robin_set() : robin_set(ht::DEFAULT_INIT_BUCKETS_SIZE) {}
131 
132  explicit robin_set(size_type bucket_count, const Hash& hash = Hash(),
133  const KeyEqual& equal = KeyEqual(),
134  const Allocator& alloc = Allocator())
135  : m_ht(bucket_count, hash, equal, alloc) {}
136 
137  robin_set(size_type bucket_count, const Allocator& alloc)
138  : robin_set(bucket_count, Hash(), KeyEqual(), alloc) {}
139 
140  robin_set(size_type bucket_count, const Hash& hash, const Allocator& alloc)
141  : robin_set(bucket_count, hash, KeyEqual(), alloc) {}
142 
143  explicit robin_set(const Allocator& alloc)
144  : robin_set(ht::DEFAULT_INIT_BUCKETS_SIZE, alloc) {}
145 
146  template <class InputIt>
147  robin_set(InputIt first, InputIt last,
149  const Hash& hash = Hash(), const KeyEqual& equal = KeyEqual(),
150  const Allocator& alloc = Allocator())
151  : robin_set(bucket_count, hash, equal, alloc) {
152  insert(first, last);
153  }
154 
155  template <class InputIt>
156  robin_set(InputIt first, InputIt last, size_type bucket_count,
157  const Allocator& alloc)
158  : robin_set(first, last, bucket_count, Hash(), KeyEqual(), alloc) {}
159 
160  template <class InputIt>
161  robin_set(InputIt first, InputIt last, size_type bucket_count,
162  const Hash& hash, const Allocator& alloc)
163  : robin_set(first, last, bucket_count, hash, KeyEqual(), alloc) {}
164 
165  robin_set(std::initializer_list<value_type> init,
167  const Hash& hash = Hash(), const KeyEqual& equal = KeyEqual(),
168  const Allocator& alloc = Allocator())
169  : robin_set(init.begin(), init.end(), bucket_count, hash, equal, alloc) {}
170 
171  robin_set(std::initializer_list<value_type> init, size_type bucket_count,
172  const Allocator& alloc)
173  : robin_set(init.begin(), init.end(), bucket_count, Hash(), KeyEqual(),
174  alloc) {}
175 
176  robin_set(std::initializer_list<value_type> init, size_type bucket_count,
177  const Hash& hash, const Allocator& alloc)
178  : robin_set(init.begin(), init.end(), bucket_count, hash, KeyEqual(),
179  alloc) {}
180 
181  robin_set& operator=(std::initializer_list<value_type> ilist) {
182  m_ht.clear();
183 
184  m_ht.reserve(ilist.size());
185  m_ht.insert(ilist.begin(), ilist.end());
186 
187  return *this;
188  }
189 
190  allocator_type get_allocator() const { return m_ht.get_allocator(); }
191 
192  /*
193  * Iterators
194  */
195  iterator begin() noexcept { return m_ht.begin(); }
196  const_iterator begin() const noexcept { return m_ht.begin(); }
197  const_iterator cbegin() const noexcept { return m_ht.cbegin(); }
198 
199  iterator end() noexcept { return m_ht.end(); }
200  const_iterator end() const noexcept { return m_ht.end(); }
201  const_iterator cend() const noexcept { return m_ht.cend(); }
202 
203  /*
204  * Capacity
205  */
206  bool empty() const noexcept { return m_ht.empty(); }
207  size_type size() const noexcept { return m_ht.size(); }
208  size_type max_size() const noexcept { return m_ht.max_size(); }
209 
210  /*
211  * Modifiers
212  */
213  void clear() noexcept { m_ht.clear(); }
214 
215  std::pair<iterator, bool> insert(const value_type& value) {
216  return m_ht.insert(value);
217  }
218 
219  std::pair<iterator, bool> insert(value_type&& value) {
220  return m_ht.insert(std::move(value));
221  }
222 
224  return m_ht.insert_hint(hint, value);
225  }
226 
228  return m_ht.insert_hint(hint, std::move(value));
229  }
230 
231  template <class InputIt>
232  void insert(InputIt first, InputIt last) {
233  m_ht.insert(first, last);
234  }
235 
236  void insert(std::initializer_list<value_type> ilist) {
237  m_ht.insert(ilist.begin(), ilist.end());
238  }
239 
240  /**
241  * Due to the way elements are stored, emplace will need to move or copy the
242  * key-value once. The method is equivalent to
243  * insert(value_type(std::forward<Args>(args)...));
244  *
245  * Mainly here for compatibility with the std::unordered_map interface.
246  */
247  template <class... Args>
248  std::pair<iterator, bool> emplace(Args&&... args) {
249  return m_ht.emplace(std::forward<Args>(args)...);
250  }
251 
252  /**
253  * Due to the way elements are stored, emplace_hint will need to move or copy
254  * the key-value once. The method is equivalent to insert(hint,
255  * value_type(std::forward<Args>(args)...));
256  *
257  * Mainly here for compatibility with the std::unordered_map interface.
258  */
259  template <class... Args>
261  return m_ht.emplace_hint(hint, std::forward<Args>(args)...);
262  }
263 
264  iterator erase(iterator pos) { return m_ht.erase(pos); }
265  iterator erase(const_iterator pos) { return m_ht.erase(pos); }
267  return m_ht.erase(first, last);
268  }
269  size_type erase(const key_type& key) { return m_ht.erase(key); }
270 
271  /**
272  * Erase the element at position 'pos'. In contrast to the regular erase()
273  * function, erase_fast() does not return an iterator. This allows it to be
274  * faster especially in hash sets with a low load factor, where finding the
275  * next nonempty bucket would be costly.
276  */
277  void erase_fast(iterator pos) { return m_ht.erase_fast(pos); }
278 
279  /**
280  * Use the hash value 'precalculated_hash' instead of hashing the key. The
281  * hash value should be the same as hash_function()(key). Useful to speed-up
282  * the lookup to the value if you already have the hash.
283  */
284  size_type erase(const key_type& key, std::size_t precalculated_hash) {
285  return m_ht.erase(key, precalculated_hash);
286  }
287 
288  /**
289  * This overload only participates in the overload resolution if the typedef
290  * KeyEqual::is_transparent exists. If so, K must be hashable and comparable
291  * to Key.
292  */
293  template <
294  class K, class KE = KeyEqual,
296  size_type erase(const K& key) {
297  return m_ht.erase(key);
298  }
299 
300  /**
301  * @copydoc erase(const K& key)
302  *
303  * Use the hash value 'precalculated_hash' instead of hashing the key. The
304  * hash value should be the same as hash_function()(key). Useful to speed-up
305  * the lookup to the value if you already have the hash.
306  */
307  template <
308  class K, class KE = KeyEqual,
310  size_type erase(const K& key, std::size_t precalculated_hash) {
311  return m_ht.erase(key, precalculated_hash);
312  }
313 
314  void swap(robin_set& other) { other.m_ht.swap(m_ht); }
315 
316  /*
317  * Lookup
318  */
319  size_type count(const Key& key) const { return m_ht.count(key); }
320 
321  /**
322  * Use the hash value 'precalculated_hash' instead of hashing the key. The
323  * hash value should be the same as hash_function()(key). Useful to speed-up
324  * the lookup if you already have the hash.
325  */
326  size_type count(const Key& key, std::size_t precalculated_hash) const {
327  return m_ht.count(key, precalculated_hash);
328  }
329 
330  /**
331  * This overload only participates in the overload resolution if the typedef
332  * KeyEqual::is_transparent exists. If so, K must be hashable and comparable
333  * to Key.
334  */
335  template <
336  class K, class KE = KeyEqual,
338  size_type count(const K& key) const {
339  return m_ht.count(key);
340  }
341 
342  /**
343  * @copydoc count(const K& key) const
344  *
345  * Use the hash value 'precalculated_hash' instead of hashing the key. The
346  * hash value should be the same as hash_function()(key). Useful to speed-up
347  * the lookup if you already have the hash.
348  */
349  template <
350  class K, class KE = KeyEqual,
352  size_type count(const K& key, std::size_t precalculated_hash) const {
353  return m_ht.count(key, precalculated_hash);
354  }
355 
356  iterator find(const Key& key) { return m_ht.find(key); }
357 
358  /**
359  * Use the hash value 'precalculated_hash' instead of hashing the key. The
360  * hash value should be the same as hash_function()(key). Useful to speed-up
361  * the lookup if you already have the hash.
362  */
363  iterator find(const Key& key, std::size_t precalculated_hash) {
364  return m_ht.find(key, precalculated_hash);
365  }
366 
367  const_iterator find(const Key& key) const { return m_ht.find(key); }
368 
369  /**
370  * @copydoc find(const Key& key, std::size_t precalculated_hash)
371  */
372  const_iterator find(const Key& key, std::size_t precalculated_hash) const {
373  return m_ht.find(key, precalculated_hash);
374  }
375 
376  /**
377  * This overload only participates in the overload resolution if the typedef
378  * KeyEqual::is_transparent exists. If so, K must be hashable and comparable
379  * to Key.
380  */
381  template <
382  class K, class KE = KeyEqual,
384  iterator find(const K& key) {
385  return m_ht.find(key);
386  }
387 
388  /**
389  * @copydoc find(const K& key)
390  *
391  * Use the hash value 'precalculated_hash' instead of hashing the key. The
392  * hash value should be the same as hash_function()(key). Useful to speed-up
393  * the lookup if you already have the hash.
394  */
395  template <
396  class K, class KE = KeyEqual,
398  iterator find(const K& key, std::size_t precalculated_hash) {
399  return m_ht.find(key, precalculated_hash);
400  }
401 
402  /**
403  * @copydoc find(const K& key)
404  */
405  template <
406  class K, class KE = KeyEqual,
408  const_iterator find(const K& key) const {
409  return m_ht.find(key);
410  }
411 
412  /**
413  * @copydoc find(const K& key)
414  *
415  * Use the hash value 'precalculated_hash' instead of hashing the key. The
416  * hash value should be the same as hash_function()(key). Useful to speed-up
417  * the lookup if you already have the hash.
418  */
419  template <
420  class K, class KE = KeyEqual,
422  const_iterator find(const K& key, std::size_t precalculated_hash) const {
423  return m_ht.find(key, precalculated_hash);
424  }
425 
426  bool contains(const Key& key) const { return m_ht.contains(key); }
427 
428  /**
429  * Use the hash value 'precalculated_hash' instead of hashing the key. The
430  * hash value should be the same as hash_function()(key). Useful to speed-up
431  * the lookup if you already have the hash.
432  */
433  bool contains(const Key& key, std::size_t precalculated_hash) const {
434  return m_ht.contains(key, precalculated_hash);
435  }
436 
437  /**
438  * This overload only participates in the overload resolution if the typedef
439  * KeyEqual::is_transparent exists. If so, K must be hashable and comparable
440  * to Key.
441  */
442  template <
443  class K, class KE = KeyEqual,
445  bool contains(const K& key) const {
446  return m_ht.contains(key);
447  }
448 
449  /**
450  * @copydoc contains(const K& key) const
451  *
452  * Use the hash value 'precalculated_hash' instead of hashing the key. The
453  * hash value should be the same as hash_function()(key). Useful to speed-up
454  * the lookup if you already have the hash.
455  */
456  template <
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);
461  }
462 
463  std::pair<iterator, iterator> equal_range(const Key& key) {
464  return m_ht.equal_range(key);
465  }
466 
467  /**
468  * Use the hash value 'precalculated_hash' instead of hashing the key. The
469  * hash value should be the same as hash_function()(key). Useful to speed-up
470  * the lookup if you already have the hash.
471  */
472  std::pair<iterator, iterator> equal_range(const Key& key,
473  std::size_t precalculated_hash) {
474  return m_ht.equal_range(key, precalculated_hash);
475  }
476 
477  std::pair<const_iterator, const_iterator> equal_range(const Key& key) const {
478  return m_ht.equal_range(key);
479  }
480 
481  /**
482  * @copydoc equal_range(const Key& key, std::size_t precalculated_hash)
483  */
484  std::pair<const_iterator, const_iterator> equal_range(
485  const Key& key, std::size_t precalculated_hash) const {
486  return m_ht.equal_range(key, precalculated_hash);
487  }
488 
489  /**
490  * This overload only participates in the overload resolution if the typedef
491  * KeyEqual::is_transparent exists. If so, K must be hashable and comparable
492  * to Key.
493  */
494  template <
495  class K, class KE = KeyEqual,
497  std::pair<iterator, iterator> equal_range(const K& key) {
498  return m_ht.equal_range(key);
499  }
500 
501  /**
502  * @copydoc equal_range(const K& key)
503  *
504  * Use the hash value 'precalculated_hash' instead of hashing the key. The
505  * hash value should be the same as hash_function()(key). Useful to speed-up
506  * the lookup if you already have the hash.
507  */
508  template <
509  class K, class KE = KeyEqual,
511  std::pair<iterator, iterator> equal_range(const K& key,
512  std::size_t precalculated_hash) {
513  return m_ht.equal_range(key, precalculated_hash);
514  }
515 
516  /**
517  * @copydoc equal_range(const K& key)
518  */
519  template <
520  class K, class KE = KeyEqual,
522  std::pair<const_iterator, const_iterator> equal_range(const K& key) const {
523  return m_ht.equal_range(key);
524  }
525 
526  /**
527  * @copydoc equal_range(const K& key, std::size_t precalculated_hash)
528  */
529  template <
530  class K, class KE = KeyEqual,
532  std::pair<const_iterator, const_iterator> equal_range(
533  const K& key, std::size_t precalculated_hash) const {
534  return m_ht.equal_range(key, precalculated_hash);
535  }
536 
537  /*
538  * Bucket interface
539  */
540  size_type bucket_count() const { return m_ht.bucket_count(); }
541  size_type max_bucket_count() const { return m_ht.max_bucket_count(); }
542 
543  /*
544  * Hash policy
545  */
546  float load_factor() const { return m_ht.load_factor(); }
547 
548  float min_load_factor() const { return m_ht.min_load_factor(); }
549  float max_load_factor() const { return m_ht.max_load_factor(); }
550 
551  /**
552  * Set the `min_load_factor` to `ml`. When the `load_factor` of the set goes
553  * below `min_load_factor` after some erase operations, the set will be
554  * shrunk when an insertion occurs. The erase method itself never shrinks
555  * the set.
556  *
557  * The default value of `min_load_factor` is 0.0f, the set never shrinks by
558  * default.
559  */
560  void min_load_factor(float ml) { m_ht.min_load_factor(ml); }
561  void max_load_factor(float ml) { m_ht.max_load_factor(ml); }
562 
563  void rehash(size_type count_) { m_ht.rehash(count_); }
564  void reserve(size_type count_) { m_ht.reserve(count_); }
565 
566  /*
567  * Observers
568  */
569  hasher hash_function() const { return m_ht.hash_function(); }
570  key_equal key_eq() const { return m_ht.key_eq(); }
571 
572  /*
573  * Other
574  */
575 
576  /**
577  * Convert a const_iterator to an iterator.
578  */
580  return m_ht.mutable_iterator(pos);
581  }
582 
583  friend bool operator==(const robin_set& lhs, const robin_set& rhs) {
584  if (lhs.size() != rhs.size()) {
585  return false;
586  }
587 
588  for (const auto& element_lhs : lhs) {
589  const auto it_element_rhs = rhs.find(element_lhs);
590  if (it_element_rhs == rhs.cend()) {
591  return false;
592  }
593  }
594 
595  return true;
596  }
597 
598  /**
599  * Serialize the set through the `serializer` parameter.
600  *
601  * The `serializer` parameter must be a function object that supports the
602  * following call:
603  * - `template<typename U> void operator()(const U& value);` where the types
604  * `std::int16_t`, `std::uint32_t`, `std::uint64_t`, `float` and `Key` must be
605  * supported for U.
606  *
607  * The implementation leaves binary compatibility (endianness, IEEE 754 for
608  * floats, ...) of the types it serializes in the hands of the `Serializer`
609  * function object if compatibility is required.
610  */
611  template <class Serializer>
612  void serialize(Serializer& serializer) const {
613  m_ht.serialize(serializer);
614  }
615 
616  /**
617  * Deserialize a previously serialized set through the `deserializer`
618  * parameter.
619  *
620  * The `deserializer` parameter must be a function object that supports the
621  * following call:
622  * - `template<typename U> U operator()();` where the types `std::int16_t`,
623  * `std::uint32_t`, `std::uint64_t`, `float` and `Key` must be supported for
624  * U.
625  *
626  * If the deserialized hash set type is hash compatible with the serialized
627  * set, the deserialization process can be sped up by setting
628  * `hash_compatible` to true. To be hash compatible, the Hash, KeyEqual and
629  * GrowthPolicy must behave the same way than the ones used on the serialized
630  * set and the StoreHash must have the same value. The `std::size_t` must also
631  * be of the same size as the one on the platform used to serialize the set.
632  * If these criteria are not met, the behaviour is undefined with
633  * `hash_compatible` sets to true.
634  *
635  * The behaviour is undefined if the type `Key` of the `robin_set` is not the
636  * same as the type used during serialization.
637  *
638  * The implementation leaves binary compatibility (endianness, IEEE 754 for
639  * floats, size of int, ...) of the types it deserializes in the hands of the
640  * `Deserializer` function object if compatibility is required.
641  */
642  template <class Deserializer>
643  static robin_set deserialize(Deserializer& deserializer,
644  bool hash_compatible = false) {
645  robin_set set(0);
646  set.m_ht.deserialize(deserializer, hash_compatible);
647 
648  return set;
649  }
650 
651  friend bool operator!=(const robin_set& lhs, const robin_set& rhs) {
652  return !operator==(lhs, rhs);
653  }
654 
655  friend void swap(robin_set& lhs, robin_set& rhs) { lhs.swap(rhs); }
656 
657  private:
658  ht m_ht;
659 };
660 
661 /**
662  * Same as `pxr_tsl::robin_set<Key, Hash, KeyEqual, Allocator, StoreHash,
663  * pxr_tsl::rh::prime_growth_policy>`.
664  */
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>
668 using robin_pg_set = robin_set<Key, Hash, KeyEqual, Allocator, StoreHash,
670 
671 } // end namespace pxr_tsl
672 
674 
675 #endif
iterator erase(const_iterator pos)
Definition: robin_set.h:265
robin_set(InputIt first, InputIt last, size_type bucket_count, const Hash &hash, const Allocator &alloc)
Definition: robin_set.h:161
iterator erase(iterator pos)
Definition: robin_set.h:264
GLint first
Definition: glcorearb.h:405
typename ht::allocator_type allocator_type
Definition: robin_set.h:119
iterator find(const Key &key, std::size_t precalculated_hash)
Definition: robin_set.h:363
size_type bucket_count() const
Definition: robin_set.h:540
iterator emplace_hint(const_iterator hint, Args &&...args)
Definition: robin_hash.h:808
void reserve(size_type count_)
Definition: robin_set.h:564
float min_load_factor() const
Definition: robin_set.h:548
void deserialize(Deserializer &deserializer, bool hash_compatible)
Definition: robin_hash.h:1122
STATIC_INLINE size_t Hash(const char *s, size_t len)
Definition: farmhash.h:2099
iterator mutable_iterator(const_iterator pos)
Definition: robin_set.h:579
void
Definition: png.h:1083
void max_load_factor(float ml)
Definition: robin_set.h:561
robin_set< Key, Hash, KeyEqual, Allocator, StoreHash, pxr_tsl::rh::prime_growth_policy > robin_pg_set
Definition: robin_set.h:669
typename ht::iterator iterator
Definition: robin_set.h:124
GLsizei const GLfloat * value
Definition: glcorearb.h:824
float load_factor() const
Definition: robin_set.h:546
hasher hash_function() const
Definition: robin_set.h:569
typename ht::key_equal key_equal
Definition: robin_set.h:118
const_iterator find(const Key &key) const
Definition: robin_set.h:367
bool contains(const Key &key, std::size_t precalculated_hash) const
Definition: robin_set.h:433
std::pair< iterator, iterator > equal_range(const Key &key)
Definition: robin_set.h:463
iterator emplace_hint(const_iterator hint, Args &&...args)
Definition: robin_set.h:260
void swap(robin_hash &other)
Definition: robin_hash.h:932
iterator insert(const_iterator hint, value_type &&value)
Definition: robin_set.h:227
std::pair< iterator, bool > insert(value_type &&value)
Definition: robin_set.h:219
void serialize(Serializer &serializer) const
Definition: robin_hash.h:1117
iterator end() noexcept
Definition: robin_set.h:199
const_iterator find(const K &key) const
Definition: robin_set.h:408
IMATH_HOSTDEVICE constexpr bool equal(T1 a, T2 b, T3 t) IMATH_NOEXCEPT
Definition: ImathFun.h:105
std::pair< iterator, iterator > equal_range(const K &key)
Definition: robin_hash.h:1033
std::pair< iterator, iterator > equal_range(const Key &key, std::size_t precalculated_hash)
Definition: robin_set.h:472
bool contains(const K &key) const
Definition: robin_hash.h:1023
bool contains(const Key &key) const
Definition: robin_set.h:426
friend bool operator==(const robin_set &lhs, const robin_set &rhs)
Definition: robin_set.h:583
size_type erase(const key_type &key, std::size_t precalculated_hash)
Definition: robin_set.h:284
void erase_fast(iterator pos)
Definition: robin_set.h:277
typename ht::const_reference const_reference
Definition: robin_set.h:121
std::pair< iterator, bool > emplace(Args &&...args)
Definition: robin_set.h:248
robin_set(std::initializer_list< value_type > init, size_type bucket_count, const Allocator &alloc)
Definition: robin_set.h:171
void insert(InputIt first, InputIt last)
Definition: robin_set.h:232
std::pair< iterator, iterator > equal_range(const K &key, std::size_t precalculated_hash)
Definition: robin_set.h:511
size_type count(const Key &key) const
Definition: robin_set.h:319
std::pair< iterator, bool > emplace(Args &&...args)
Definition: robin_hash.h:803
robin_set(InputIt first, InputIt last, size_type bucket_count, const Allocator &alloc)
Definition: robin_set.h:156
size_type count(const Key &key, std::size_t precalculated_hash) const
Definition: robin_set.h:326
std::pair< const_iterator, const_iterator > equal_range(const K &key) const
Definition: robin_set.h:522
iterator insert_hint(const_iterator hint, P &&value)
Definition: robin_hash.h:751
size_type size() const noexcept
Definition: robin_set.h:207
const_iterator cbegin() const noexcept
Definition: robin_set.h:197
size_type count(const K &key) const
Definition: robin_hash.h:989
const_iterator find(const Key &key, std::size_t precalculated_hash) const
Definition: robin_set.h:372
const_iterator cend() const noexcept
Definition: robin_hash.h:716
void rehash(size_type count_)
Definition: robin_set.h:563
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())
Definition: robin_set.h:165
robin_set(const Allocator &alloc)
Definition: robin_set.h:143
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:108
typename ht::difference_type difference_type
Definition: robin_set.h:116
size_type count(const K &key, std::size_t precalculated_hash) const
Definition: robin_set.h:352
const_iterator begin() const noexcept
Definition: robin_set.h:196
iterator find(const K &key)
Definition: robin_set.h:384
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())
Definition: robin_set.h:147
typename ht::const_pointer const_pointer
Definition: robin_set.h:123
void insert(std::initializer_list< value_type > ilist)
Definition: robin_set.h:236
friend bool operator!=(const robin_set &lhs, const robin_set &rhs)
Definition: robin_set.h:651
constexpr auto set(type rhs) -> int
Definition: core.h:610
static robin_set deserialize(Deserializer &deserializer, bool hash_compatible=false)
Definition: robin_set.h:643
const_iterator find(const K &key, std::size_t precalculated_hash) const
Definition: robin_set.h:422
GLuint GLuint end
Definition: glcorearb.h:475
friend void swap(robin_set &lhs, robin_set &rhs)
Definition: robin_set.h:655
size_type erase(const K &key)
Definition: robin_set.h:296
std::pair< iterator, bool > insert(P &&value)
Definition: robin_hash.h:746
iterator begin() noexcept
Definition: robin_set.h:195
bool empty() const noexcept
Definition: robin_set.h:206
void clear() noexcept
Definition: robin_set.h:213
typename ht::pointer pointer
Definition: robin_set.h:122
size_type max_size() const noexcept
Definition: robin_hash.h:727
robin_set(size_type bucket_count, const Hash &hash=Hash(), const KeyEqual &equal=KeyEqual(), const Allocator &alloc=Allocator())
Definition: robin_set.h:132
iterator erase(const_iterator first, const_iterator last)
Definition: robin_set.h:266
typename ht::reference reference
Definition: robin_set.h:120
void min_load_factor(float ml)
Definition: robin_set.h:560
typename ht::value_type value_type
Definition: robin_set.h:114
size_type erase(const K &key, std::size_t precalculated_hash)
Definition: robin_set.h:310
const_iterator cbegin() const noexcept
Definition: robin_hash.h:703
std::pair< const_iterator, const_iterator > equal_range(const Key &key, std::size_t precalculated_hash) const
Definition: robin_set.h:484
size_type erase(const key_type &key)
Definition: robin_set.h:269
key_equal key_eq() const
Definition: robin_set.h:570
std::pair< iterator, bool > insert(const value_type &value)
Definition: robin_set.h:215
__hostdev__ uint64_t last(uint32_t i) const
Definition: NanoVDB.h:5976
iterator mutable_iterator(const_iterator pos)
Definition: robin_hash.h:1112
std::pair< iterator, iterator > equal_range(const K &key)
Definition: robin_set.h:497
bool contains(const K &key, std::size_t precalculated_hash) const
Definition: robin_set.h:459
size_type max_size() const noexcept
Definition: robin_set.h:208
robin_set(std::initializer_list< value_type > init, size_type bucket_count, const Hash &hash, const Allocator &alloc)
Definition: robin_set.h:176
const_iterator cend() const noexcept
Definition: robin_set.h:201
size_type max_bucket_count() const
Definition: robin_set.h:541
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
std::pair< const_iterator, const_iterator > equal_range(const K &key, std::size_t precalculated_hash) const
Definition: robin_set.h:532
const_iterator end() const noexcept
Definition: robin_set.h:200
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
iterator insert(const_iterator hint, const value_type &value)
Definition: robin_set.h:223
**If you just want to fire and args
Definition: thread.h:618
size_type size() const noexcept
Definition: robin_hash.h:725
robin_set(size_type bucket_count, const Allocator &alloc)
Definition: robin_set.h:137
void serialize(Serializer &serializer) const
Definition: robin_set.h:612
size_type count(const K &key) const
Definition: robin_set.h:338
robin_set(size_type bucket_count, const Hash &hash, const Allocator &alloc)
Definition: robin_set.h:140
void swap(robin_set &other)
Definition: robin_set.h:314
allocator_type get_allocator() const
Definition: robin_hash.h:685
bool contains(const K &key) const
Definition: robin_set.h:445
iterator find(const Key &key)
Definition: robin_set.h:356
allocator_type get_allocator() const
Definition: robin_set.h:190
float max_load_factor() const
Definition: robin_set.h:549
iterator find(const K &key, std::size_t precalculated_hash)
Definition: robin_set.h:398
typename ht::hasher hasher
Definition: robin_set.h:117
std::pair< const_iterator, const_iterator > equal_range(const Key &key) const
Definition: robin_set.h:477
typename ht::key_type key_type
Definition: robin_set.h:113
typename ht::size_type size_type
Definition: robin_set.h:115
typename ht::const_iterator const_iterator
Definition: robin_set.h:125
robin_set & operator=(std::initializer_list< value_type > ilist)
Definition: robin_set.h:181