Loading...
Searching...
No Matches
bucket_entry< ValueType, StoreHash > Class Template Reference

Each bucket entry has: More...

#include <robin_hash.h>

+ Inheritance diagram for bucket_entry< ValueType, StoreHash >:

Public Types

using value_type = ValueType
 
using distance_type = std::int16_t
 

Public Member Functions

 bucket_entry (bool last_bucket) noexcept
 
 bucket_entry (const bucket_entry &other) noexcept(std::is_nothrow_copy_constructible< value_type >::value)
 
 bucket_entry (bucket_entry &&other) noexcept(std::is_nothrow_move_constructible< value_type >::value)
 Never really used, but still necessary as we must call resize on an empty std::vector<bucket_entry>.
 
bucket_entryoperator= (const bucket_entry &other) noexcept(std::is_nothrow_copy_constructible< value_type >::value)
 
bucket_entryoperator= (bucket_entry &&)=delete
 
void clear () noexcept
 
bool empty () const noexcept
 
value_type & value () noexcept
 
const value_type & value () const noexcept
 
distance_type dist_from_ideal_bucket () const noexcept
 
bool last_bucket () const noexcept
 
void set_as_last_bucket () noexcept
 
template<typename... Args>
void set_value_of_empty_bucket (distance_type dist_from_ideal_bucket, truncated_hash_type hash, Args &&... value_type_args)
 
void swap_with_value_in_bucket (distance_type &dist_from_ideal_bucket, truncated_hash_type &hash, value_type &value)
 
- Public Member Functions inherited from bucket_entry_hash< StoreHash >
bool bucket_hash_equal (std::size_t) const noexcept
 
truncated_hash_type truncated_hash () const noexcept
 

Static Public Member Functions

static truncated_hash_type truncate_hash (std::size_t hash) noexcept
 

Static Public Attributes

static const distance_type EMPTY_MARKER_DIST_FROM_IDEAL_BUCKET = -1
 
static const distance_type DIST_FROM_IDEAL_BUCKET_LIMIT = 4096
 

Additional Inherited Members

- Protected Member Functions inherited from bucket_entry_hash< StoreHash >
void set_hash (truncated_hash_type) noexcept
 

Detailed Description

template<typename ValueType, bool StoreHash>
class pxr_tsl::detail_robin_hash::bucket_entry< ValueType, StoreHash >

Each bucket entry has:

  • A value of type ValueType.
  • An integer to store how far the value of the bucket, if any, is from its ideal bucket (ex: if the current bucket 5 has the value 'foo' and ‘hash('foo’) % nb_buckets== 3,dist_from_ideal_bucket()` will return 2 as the current value of the bucket is two buckets away from its ideal bucket) If there is no value in the bucket (i.e. empty() is true) dist_from_ideal_bucket() will be < 0.
  • A marker which tells us if the bucket is the last bucket of the bucket array (useful for the iterator of the hash table).
  • If StoreHash is true, 32 bits of the hash of the value, if any, are also stored in the bucket. If the size of the hash is more than 32 bits, it is truncated. We don't store the full hash as storing the hash is a potential opportunity to use the unused space due to the alignment of the bucket_entry structure. We can thus potentially store the hash without any extra space (which would not be possible with 64 bits of the hash).

Definition at line 172 of file robin_hash.h.

Member Typedef Documentation

◆ distance_type

using distance_type = std::int16_t

Definition at line 177 of file robin_hash.h.

◆ value_type

using value_type = ValueType

Definition at line 176 of file robin_hash.h.

Constructor & Destructor Documentation

◆ bucket_entry() [1/4]

bucket_entry ( )
inlinenoexcept

Definition at line 179 of file robin_hash.h.

◆ bucket_entry() [2/4]

bucket_entry ( bool  last_bucket)
inlinenoexcept

Definition at line 186 of file robin_hash.h.

◆ bucket_entry() [3/4]

bucket_entry ( const bucket_entry< ValueType, StoreHash > &  other)
inlinenoexcept

Definition at line 193 of file robin_hash.h.

◆ bucket_entry() [4/4]

bucket_entry ( bucket_entry< ValueType, StoreHash > &&  other)
inlinenoexcept

Never really used, but still necessary as we must call resize on an empty std::vector<bucket_entry>.

and we need to support move-only types. See robin_hash constructor for details.

Definition at line 210 of file robin_hash.h.

◆ ~bucket_entry()

~bucket_entry ( )
inlinenoexcept

Definition at line 242 of file robin_hash.h.

Member Function Documentation

◆ clear()

void clear ( )
inlinenoexcept

Definition at line 244 of file robin_hash.h.

◆ dist_from_ideal_bucket()

distance_type dist_from_ideal_bucket ( ) const
inlinenoexcept

Definition at line 265 of file robin_hash.h.

◆ empty()

bool empty ( ) const
inlinenoexcept

Definition at line 251 of file robin_hash.h.

◆ last_bucket()

bool last_bucket ( ) const
inlinenoexcept

Definition at line 269 of file robin_hash.h.

◆ operator=()

bucket_entry & operator= ( const bucket_entry< ValueType, StoreHash > &  other)
inlinenoexcept

Definition at line 222 of file robin_hash.h.

◆ set_as_last_bucket()

void set_as_last_bucket ( )
inlinenoexcept

Definition at line 271 of file robin_hash.h.

◆ set_value_of_empty_bucket()

void set_value_of_empty_bucket ( distance_type  dist_from_ideal_bucket,
truncated_hash_type  hash,
Args &&...  value_type_args 
)
inline

Definition at line 274 of file robin_hash.h.

◆ swap_with_value_in_bucket()

void swap_with_value_in_bucket ( distance_type &  dist_from_ideal_bucket,
truncated_hash_type &  hash,
value_type &  value 
)
inline

Definition at line 288 of file robin_hash.h.

◆ truncate_hash()

static truncated_hash_type truncate_hash ( std::size_t  hash)
inlinestaticnoexcept

Definition at line 306 of file robin_hash.h.

◆ value() [1/2]

const value_type & value ( ) const
inlinenoexcept

Definition at line 260 of file robin_hash.h.

◆ value() [2/2]

value_type & value ( )
inlinenoexcept

Definition at line 255 of file robin_hash.h.

Member Data Documentation

◆ DIST_FROM_IDEAL_BUCKET_LIMIT

const distance_type DIST_FROM_IDEAL_BUCKET_LIMIT = 4096
static

Definition at line 318 of file robin_hash.h.

◆ EMPTY_MARKER_DIST_FROM_IDEAL_BUCKET

const distance_type EMPTY_MARKER_DIST_FROM_IDEAL_BUCKET = -1
static

Definition at line 317 of file robin_hash.h.


The documentation for this class was generated from the following file: