Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
HashTable< Key, KeyValue, HashTableDetail, Hash, KeyEqual > Class Template Reference

#include <HashTable.h>

Inheritance diagram for HashTable< Key, KeyValue, HashTableDetail, Hash, KeyEqual >:
UnorderedMap< SwingConeLimits, GeometryRef, SwingConeLimitsHasher > UnorderedMap< SwingPyramidLimits, GeometryRef, SwingPyramidLimitsHasher > UnorderedMap< float, GeometryRef > UnorderedMap< TaperedCylinder, GeometryRef, TaperedCylinderHasher > UnorderedMap< uint32, Ref > UnorderedMap< GeometryRef, uint32 > UnorderedMap< string_view, const RTTI * > UnorderedMap< uint32, const RTTI * > UnorderedMap< uint32, String > UnorderedMap< String, uint32 > UnorderedMap< String, ClassDescription > UnorderedMap< Identifier, ObjectInfo > UnorderedMap< const void *, ObjectInfo > UnorderedSet< const RTTI * > UnorderedMap< Key, Value, Hash, KeyEqual > UnorderedSet< Key, Hash, KeyEqual >

Classes

class  const_iterator
 Const iterator. More...
 
class  iterator
 Non-const iterator. More...
 

Public Types

using value_type = KeyValue
 Properties.
 
using size_type = uint32
 
using difference_type = ptrdiff_t
 

Public Member Functions

 HashTable ()=default
 Default constructor.
 
 HashTable (const HashTable &inRHS)
 Copy constructor.
 
 HashTable (HashTable &&ioRHS) noexcept
 Move constructor.
 
HashTableoperator= (const HashTable &inRHS)
 Assignment operator.
 
HashTableoperator= (HashTable &&ioRHS) noexcept
 Move assignment operator.
 
 ~HashTable ()
 Destructor.
 
void reserve (size_type inMaxSize)
 Reserve memory for a certain number of elements.
 
void clear ()
 Destroy the entire hash table.
 
iterator begin ()
 Iterator to first element.
 
iterator end ()
 Iterator to one beyond last element.
 
const_iterator begin () const
 Iterator to first element.
 
const_iterator end () const
 Iterator to one beyond last element.
 
const_iterator cbegin () const
 Iterator to first element.
 
const_iterator cend () const
 Iterator to one beyond last element.
 
size_type bucket_count () const
 Number of buckets in the table.
 
constexpr size_type max_bucket_count () const
 Max number of buckets that the table can have.
 
bool empty () const
 Check if there are no elements in the table.
 
size_type size () const
 Number of elements in the table.
 
constexpr size_type max_size () const
 Max number of elements that the table can hold.
 
constexpr float max_load_factor () const
 Get the max load factor for this table (max number of elements / number of buckets)
 
std::pair< iterator, bool > insert (const value_type &inValue)
 Insert a new element, returns iterator and if the element was inserted.
 
const_iterator find (const Key &inKey) const
 Find an element, returns iterator to element or end() if not found.
 
void erase (const const_iterator &inIterator)
 Erase an element by iterator.
 
size_type erase (const Key &inKey)
 Erase an element by key.
 
void swap (HashTable &ioRHS) noexcept
 Swap the contents of two hash tables.
 
void rehash (size_type)
 

Protected Member Functions

KeyValue & GetElement (size_type inIndex) const
 Get an element by index.
 
template<bool InsertAfterGrow = false>
bool InsertKey (const Key &inKey, size_type &outIndex)
 

Detailed Description

template<class Key, class KeyValue, class HashTableDetail, class Hash, class KeyEqual>
class HashTable< Key, KeyValue, HashTableDetail, Hash, KeyEqual >

Helper class for implementing an UnorderedSet or UnorderedMap Based on CppCon 2017: Matt Kulukundis "Designing a Fast, Efficient, Cache-friendly Hash Table, Step by Step" See: https://www.youtube.com/watch?v=ncHmEUmJZf4

Member Typedef Documentation

◆ difference_type

template<class Key , class KeyValue , class HashTableDetail , class Hash , class KeyEqual >
using HashTable< Key, KeyValue, HashTableDetail, Hash, KeyEqual >::difference_type = ptrdiff_t

◆ size_type

template<class Key , class KeyValue , class HashTableDetail , class Hash , class KeyEqual >
using HashTable< Key, KeyValue, HashTableDetail, Hash, KeyEqual >::size_type = uint32

◆ value_type

template<class Key , class KeyValue , class HashTableDetail , class Hash , class KeyEqual >
using HashTable< Key, KeyValue, HashTableDetail, Hash, KeyEqual >::value_type = KeyValue

Properties.

Constructor & Destructor Documentation

◆ HashTable() [1/3]

template<class Key , class KeyValue , class HashTableDetail , class Hash , class KeyEqual >
HashTable< Key, KeyValue, HashTableDetail, Hash, KeyEqual >::HashTable ( )
default

Default constructor.

◆ HashTable() [2/3]

template<class Key , class KeyValue , class HashTableDetail , class Hash , class KeyEqual >
HashTable< Key, KeyValue, HashTableDetail, Hash, KeyEqual >::HashTable ( const HashTable< Key, KeyValue, HashTableDetail, Hash, KeyEqual > &  inRHS)
inline

Copy constructor.

◆ HashTable() [3/3]

template<class Key , class KeyValue , class HashTableDetail , class Hash , class KeyEqual >
HashTable< Key, KeyValue, HashTableDetail, Hash, KeyEqual >::HashTable ( HashTable< Key, KeyValue, HashTableDetail, Hash, KeyEqual > &&  ioRHS)
inlinenoexcept

Move constructor.

◆ ~HashTable()

template<class Key , class KeyValue , class HashTableDetail , class Hash , class KeyEqual >
HashTable< Key, KeyValue, HashTableDetail, Hash, KeyEqual >::~HashTable ( )
inline

Destructor.

Member Function Documentation

◆ begin() [1/2]

template<class Key , class KeyValue , class HashTableDetail , class Hash , class KeyEqual >
iterator HashTable< Key, KeyValue, HashTableDetail, Hash, KeyEqual >::begin ( )
inline

Iterator to first element.

◆ begin() [2/2]

template<class Key , class KeyValue , class HashTableDetail , class Hash , class KeyEqual >
const_iterator HashTable< Key, KeyValue, HashTableDetail, Hash, KeyEqual >::begin ( ) const
inline

Iterator to first element.

◆ bucket_count()

template<class Key , class KeyValue , class HashTableDetail , class Hash , class KeyEqual >
size_type HashTable< Key, KeyValue, HashTableDetail, Hash, KeyEqual >::bucket_count ( ) const
inline

Number of buckets in the table.

◆ cbegin()

template<class Key , class KeyValue , class HashTableDetail , class Hash , class KeyEqual >
const_iterator HashTable< Key, KeyValue, HashTableDetail, Hash, KeyEqual >::cbegin ( ) const
inline

Iterator to first element.

◆ cend()

template<class Key , class KeyValue , class HashTableDetail , class Hash , class KeyEqual >
const_iterator HashTable< Key, KeyValue, HashTableDetail, Hash, KeyEqual >::cend ( ) const
inline

Iterator to one beyond last element.

◆ clear()

template<class Key , class KeyValue , class HashTableDetail , class Hash , class KeyEqual >
void HashTable< Key, KeyValue, HashTableDetail, Hash, KeyEqual >::clear ( )
inline

Destroy the entire hash table.

◆ empty()

template<class Key , class KeyValue , class HashTableDetail , class Hash , class KeyEqual >
bool HashTable< Key, KeyValue, HashTableDetail, Hash, KeyEqual >::empty ( ) const
inline

Check if there are no elements in the table.

◆ end() [1/2]

template<class Key , class KeyValue , class HashTableDetail , class Hash , class KeyEqual >
iterator HashTable< Key, KeyValue, HashTableDetail, Hash, KeyEqual >::end ( )
inline

Iterator to one beyond last element.

◆ end() [2/2]

template<class Key , class KeyValue , class HashTableDetail , class Hash , class KeyEqual >
const_iterator HashTable< Key, KeyValue, HashTableDetail, Hash, KeyEqual >::end ( ) const
inline

Iterator to one beyond last element.

◆ erase() [1/2]

template<class Key , class KeyValue , class HashTableDetail , class Hash , class KeyEqual >
void HashTable< Key, KeyValue, HashTableDetail, Hash, KeyEqual >::erase ( const const_iterator inIterator)
inline

Erase an element by iterator.

◆ erase() [2/2]

template<class Key , class KeyValue , class HashTableDetail , class Hash , class KeyEqual >
size_type HashTable< Key, KeyValue, HashTableDetail, Hash, KeyEqual >::erase ( const Key &  inKey)
inline

Erase an element by key.

◆ find()

template<class Key , class KeyValue , class HashTableDetail , class Hash , class KeyEqual >
const_iterator HashTable< Key, KeyValue, HashTableDetail, Hash, KeyEqual >::find ( const Key &  inKey) const
inline

Find an element, returns iterator to element or end() if not found.

◆ GetElement()

template<class Key , class KeyValue , class HashTableDetail , class Hash , class KeyEqual >
KeyValue & HashTable< Key, KeyValue, HashTableDetail, Hash, KeyEqual >::GetElement ( size_type  inIndex) const
inlineprotected

Get an element by index.

◆ insert()

template<class Key , class KeyValue , class HashTableDetail , class Hash , class KeyEqual >
std::pair< iterator, bool > HashTable< Key, KeyValue, HashTableDetail, Hash, KeyEqual >::insert ( const value_type inValue)
inline

Insert a new element, returns iterator and if the element was inserted.

◆ InsertKey()

template<class Key , class KeyValue , class HashTableDetail , class Hash , class KeyEqual >
template<bool InsertAfterGrow = false>
bool HashTable< Key, KeyValue, HashTableDetail, Hash, KeyEqual >::InsertKey ( const Key &  inKey,
size_type outIndex 
)
inlineprotected

Insert a key into the map, returns true if the element was inserted, false if it already existed. outIndex is the index at which the element should be constructed / where it is located.

◆ max_bucket_count()

template<class Key , class KeyValue , class HashTableDetail , class Hash , class KeyEqual >
constexpr size_type HashTable< Key, KeyValue, HashTableDetail, Hash, KeyEqual >::max_bucket_count ( ) const
inlineconstexpr

Max number of buckets that the table can have.

◆ max_load_factor()

template<class Key , class KeyValue , class HashTableDetail , class Hash , class KeyEqual >
constexpr float HashTable< Key, KeyValue, HashTableDetail, Hash, KeyEqual >::max_load_factor ( ) const
inlineconstexpr

Get the max load factor for this table (max number of elements / number of buckets)

◆ max_size()

template<class Key , class KeyValue , class HashTableDetail , class Hash , class KeyEqual >
constexpr size_type HashTable< Key, KeyValue, HashTableDetail, Hash, KeyEqual >::max_size ( ) const
inlineconstexpr

Max number of elements that the table can hold.

◆ operator=() [1/2]

template<class Key , class KeyValue , class HashTableDetail , class Hash , class KeyEqual >
HashTable & HashTable< Key, KeyValue, HashTableDetail, Hash, KeyEqual >::operator= ( const HashTable< Key, KeyValue, HashTableDetail, Hash, KeyEqual > &  inRHS)
inline

Assignment operator.

◆ operator=() [2/2]

template<class Key , class KeyValue , class HashTableDetail , class Hash , class KeyEqual >
HashTable & HashTable< Key, KeyValue, HashTableDetail, Hash, KeyEqual >::operator= ( HashTable< Key, KeyValue, HashTableDetail, Hash, KeyEqual > &&  ioRHS)
inlinenoexcept

Move assignment operator.

◆ rehash()

template<class Key , class KeyValue , class HashTableDetail , class Hash , class KeyEqual >
void HashTable< Key, KeyValue, HashTableDetail, Hash, KeyEqual >::rehash ( size_type  )
inline

In place re-hashing of all elements in the table. Removes all cBucketDeleted elements The std version takes a bucket count, but we just re-hash to the same size.

◆ reserve()

template<class Key , class KeyValue , class HashTableDetail , class Hash , class KeyEqual >
void HashTable< Key, KeyValue, HashTableDetail, Hash, KeyEqual >::reserve ( size_type  inMaxSize)
inline

Reserve memory for a certain number of elements.

◆ size()

template<class Key , class KeyValue , class HashTableDetail , class Hash , class KeyEqual >
size_type HashTable< Key, KeyValue, HashTableDetail, Hash, KeyEqual >::size ( ) const
inline

Number of elements in the table.

◆ swap()

template<class Key , class KeyValue , class HashTableDetail , class Hash , class KeyEqual >
void HashTable< Key, KeyValue, HashTableDetail, Hash, KeyEqual >::swap ( HashTable< Key, KeyValue, HashTableDetail, Hash, KeyEqual > &  ioRHS)
inlinenoexcept

Swap the contents of two hash tables.


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