AGXDynamics  2.31.1.0
agx::LinearProbingHashTable< KeyT, DataT, HashT, AllocatorT > Class Template Reference

Inheritance with partial specialization due to bug with ref_ptr containers. More...

#include <LinearProbingHashTable.h>

+ Inheritance diagram for agx::LinearProbingHashTable< KeyT, DataT, HashT, AllocatorT >:

Public Types

using bucket_type = PairT
 
enum  ClearPolicy
 
using const_reference = const PairT &
 
typedef LinearProbingHashTableImplementation< KeyT, DataT, HashT, AllocatorT > Implementation
 
using key_type = KeyT
 
using reference = PairT &
 
using size_type = size_t
 
using value_type = DataT
 

Public Member Functions

 LinearProbingHashTable ()
 
iterator begin ()
 Iterator to first element in hash table. More...
 
const_iterator begin () const
 Iterator to first element in hash table. More...
 
size_t capacity () const
 
void clear (int=0)
 Remove all elements, keeping full capacity. More...
 
bool contains (const KeyT &k) const
 Check if the hash table contains a key/value pair for the given key. More...
 
size_t count (const KeyT &k) const
 Count the number of key/value pairs matching the given key. More...
 
bool empty () const
 
iterator end ()
 Iterator marking end of hash table. More...
 
const_iterator end () const
 Iterator marking end of hash table. More...
 
bool erase (const KeyT &key)
 Erase an element from the hash table. More...
 
iterator erase (iterator it)
 Erase an element from the hash table. More...
 
iterator find (const KeyT &key)
 Find a key/value pair in the hash table given a key. More...
 
const_iterator find (const KeyT &key) const
 Find a key/value pair in the hash table given a key. More...
 
const DataT get_or_return_default (const KeyT &k) const
 
insert_iterator insert (const KeyT &key, const DataT value)
 Insert a key/value pair into the hash table. More...
 
insert_iterator insert (const std::pair< KeyT, DataT > &p)
 
void insert (const_iterator begin, const_iterator end)
 Insert all elements in the given range. More...
 
void insert_unique (KeyT &&key, DataT &&value)
 Insert a key/value pair into the hash table assuming that the given key does not already exist in the hash table. More...
 
void insert_unique (std::pair< KeyT, DataT > &&p)
 
DataT & operator[] (const KeyT &key)
 Return the value associated with the given key. More...
 
const void * ptr () const
 
void reserve (size_t num_elems)
 Make room for this many elements in the hash table. More...
 
DataT set_get (const KeyT &key, const DataT &new_value)
 
size_t size () const
 
void swap (LinearProbingHashTableImplementation &other)
 
DataT * try_get (const KeyT &k)
 Find the value associated with the given key. More...
 
const DataT * try_get (const KeyT &k) const
 Find the value associated with the given key. More...
 

Protected Member Functions

void erase_bucket (size_t bucket)
 
size_t find_filled_bucket (const T2 &key) const
 

Detailed Description

template<typename KeyT, typename DataT, typename HashT = agx::HashFn<KeyT>, typename AllocatorT = ByteAllocator>
class agx::LinearProbingHashTable< KeyT, DataT, HashT, AllocatorT >

Inheritance with partial specialization due to bug with ref_ptr containers.

Partial specialization only works on classes, not methods which would have been a cleaner solution.

See full comment in HashSet.h

Definition at line 871 of file LinearProbingHashTable.h.

Member Typedef Documentation

◆ bucket_type

using agx::LinearProbingHashTableImplementation< KeyT, DataT , HashT, AllocatorT >::bucket_type = PairT
inherited

Definition at line 64 of file LinearProbingHashTable.h.

◆ const_reference

using agx::LinearProbingHashTableImplementation< KeyT, DataT , HashT, AllocatorT >::const_reference = const PairT&
inherited

Definition at line 66 of file LinearProbingHashTable.h.

◆ Implementation

template<typename KeyT, typename DataT, typename HashT = agx::HashFn<KeyT>, typename AllocatorT = ByteAllocator>
typedef LinearProbingHashTableImplementation<KeyT, DataT, HashT, AllocatorT> agx::LinearProbingHashTable< KeyT, DataT, HashT, AllocatorT >::Implementation

Definition at line 874 of file LinearProbingHashTable.h.

◆ key_type

using agx::LinearProbingHashTableImplementation< KeyT, DataT , HashT, AllocatorT >::key_type = KeyT
inherited

Definition at line 61 of file LinearProbingHashTable.h.

◆ reference

using agx::LinearProbingHashTableImplementation< KeyT, DataT , HashT, AllocatorT >::reference = PairT&
inherited

Definition at line 65 of file LinearProbingHashTable.h.

◆ size_type

using agx::LinearProbingHashTableImplementation< KeyT, DataT , HashT, AllocatorT >::size_type = size_t
inherited

Definition at line 62 of file LinearProbingHashTable.h.

◆ value_type

using agx::LinearProbingHashTableImplementation< KeyT, DataT , HashT, AllocatorT >::value_type = DataT
inherited

Definition at line 63 of file LinearProbingHashTable.h.

Member Enumeration Documentation

◆ ClearPolicy

Constructor & Destructor Documentation

◆ LinearProbingHashTable()

template<typename KeyT, typename DataT, typename HashT = agx::HashFn<KeyT>, typename AllocatorT = ByteAllocator>
agx::LinearProbingHashTable< KeyT, DataT, HashT, AllocatorT >::LinearProbingHashTable ( )
inline

Definition at line 876 of file LinearProbingHashTable.h.

Member Function Documentation

◆ begin() [1/2]

iterator agx::LinearProbingHashTableImplementation< KeyT, DataT , HashT, AllocatorT >::begin ( )
inlineinherited

Iterator to first element in hash table.

Definition at line 360 of file LinearProbingHashTable.h.

◆ begin() [2/2]

const_iterator agx::LinearProbingHashTableImplementation< KeyT, DataT , HashT, AllocatorT >::begin ( ) const
inlineinherited

Iterator to first element in hash table.

Definition at line 372 of file LinearProbingHashTable.h.

◆ capacity()

size_t agx::LinearProbingHashTableImplementation< KeyT, DataT , HashT, AllocatorT >::capacity ( ) const
inlineinherited
Returns
The total number of buckets in the hash table.

Definition at line 406 of file LinearProbingHashTable.h.

◆ clear()

void agx::LinearProbingHashTableImplementation< KeyT, DataT , HashT, AllocatorT >::clear ( int  = 0)
inlineinherited

Remove all elements, keeping full capacity.

Definition at line 656 of file LinearProbingHashTable.h.

◆ contains()

bool agx::LinearProbingHashTableImplementation< KeyT, DataT , HashT, AllocatorT >::contains ( const KeyT &  k) const
inlineinherited

Check if the hash table contains a key/value pair for the given key.

Parameters
kKey to look for.
Returns
True if the key exists in the hash table. False otherwise.

Definition at line 455 of file LinearProbingHashTable.h.

◆ count()

size_t agx::LinearProbingHashTableImplementation< KeyT, DataT , HashT, AllocatorT >::count ( const KeyT &  k) const
inlineinherited

Count the number of key/value pairs matching the given key.

Will always be either 0 or 1.

Parameters
kThe key to count.
Returns
1 if the key exists in the hash table, 0 otherwise.

Definition at line 466 of file LinearProbingHashTable.h.

◆ empty()

bool agx::LinearProbingHashTableImplementation< KeyT, DataT , HashT, AllocatorT >::empty ( ) const
inlineinherited
Returns
True if the hash table contains no key/value pairs. False otherwise.

Definition at line 414 of file LinearProbingHashTable.h.

◆ end() [1/2]

iterator agx::LinearProbingHashTableImplementation< KeyT, DataT , HashT, AllocatorT >::end ( )
inlineinherited

Iterator marking end of hash table.

Definition at line 385 of file LinearProbingHashTable.h.

◆ end() [2/2]

const_iterator agx::LinearProbingHashTableImplementation< KeyT, DataT , HashT, AllocatorT >::end ( ) const
inlineinherited

Iterator marking end of hash table.

Definition at line 392 of file LinearProbingHashTable.h.

◆ erase() [1/2]

bool agx::LinearProbingHashTableImplementation< KeyT, DataT , HashT, AllocatorT >::erase ( const KeyT &  key)
inlineinherited

Erase an element from the hash table.

Returns
True if an element was removed, false otherwise.

Definition at line 630 of file LinearProbingHashTable.h.

◆ erase() [2/2]

iterator agx::LinearProbingHashTableImplementation< KeyT, DataT , HashT, AllocatorT >::erase ( iterator  it)
inlineinherited

Erase an element from the hash table.

Returns
An iterator to the next element, or the end iterator if there is no such element.

Definition at line 645 of file LinearProbingHashTable.h.

◆ erase_bucket()

void agx::LinearProbingHashTableImplementation< KeyT, DataT , HashT, AllocatorT >::erase_bucket ( size_t  bucket)
inlineprotectedinherited

Definition at line 754 of file LinearProbingHashTable.h.

◆ find() [1/2]

iterator agx::LinearProbingHashTableImplementation< KeyT, DataT , HashT, AllocatorT >::find ( const KeyT &  key)
inlineinherited

Find a key/value pair in the hash table given a key.

Parameters
keyThe key to look for.
Returns
Iterator to the key/value pair, or the end iterator if no such key exists.

Definition at line 426 of file LinearProbingHashTable.h.

◆ find() [2/2]

const_iterator agx::LinearProbingHashTableImplementation< KeyT, DataT , HashT, AllocatorT >::find ( const KeyT &  key) const
inlineinherited

Find a key/value pair in the hash table given a key.

Parameters
keyThe key to look for.
Returns
Iterator to the key/value pair, or the end iterator if no such key exists.

Definition at line 440 of file LinearProbingHashTable.h.

◆ find_filled_bucket()

size_t agx::LinearProbingHashTableImplementation< KeyT, DataT , HashT, AllocatorT >::find_filled_bucket ( const T2 &  key) const
inlineprotectedinherited

Definition at line 737 of file LinearProbingHashTable.h.

◆ get_or_return_default()

const DataT agx::LinearProbingHashTableImplementation< KeyT, DataT , HashT, AllocatorT >::get_or_return_default ( const KeyT &  k) const
inlineinherited

Definition at line 502 of file LinearProbingHashTable.h.

◆ insert() [1/3]

insert_iterator agx::LinearProbingHashTableImplementation< KeyT, DataT , HashT, AllocatorT >::insert ( const KeyT &  key,
const DataT  value 
)
inlineinherited

Insert a key/value pair into the hash table.

The current value is overwritten if a key/value pair with an equal key already exists.

Parameters
keyThe key to insert.
valueThe value to associate with the given key.
Returns
An input iterator to the inserted key/value pair.

Definition at line 521 of file LinearProbingHashTable.h.

◆ insert() [2/3]

insert_iterator agx::LinearProbingHashTableImplementation< KeyT, DataT , HashT, AllocatorT >::insert ( const std::pair< KeyT, DataT > &  p)
inlineinherited

Definition at line 540 of file LinearProbingHashTable.h.

◆ insert() [3/3]

void agx::LinearProbingHashTableImplementation< KeyT, DataT , HashT, AllocatorT >::insert ( const_iterator  begin,
const_iterator  end 
)
inlineinherited

Insert all elements in the given range.

Parameters
beginBeginning of the range.
endEnd of the range.

Definition at line 551 of file LinearProbingHashTable.h.

◆ insert_unique() [1/2]

void agx::LinearProbingHashTableImplementation< KeyT, DataT , HashT, AllocatorT >::insert_unique ( KeyT &&  key,
DataT &&  value 
)
inlineinherited

Insert a key/value pair into the hash table assuming that the given key does not already exist in the hash table.

It is undefined behavior to call this method with a key that does already exist in the hash table.

Parameters
keyThe key to insert.
valueThe value to associate with the key.

Definition at line 566 of file LinearProbingHashTable.h.

◆ insert_unique() [2/2]

void agx::LinearProbingHashTableImplementation< KeyT, DataT , HashT, AllocatorT >::insert_unique ( std::pair< KeyT, DataT > &&  p)
inlineinherited

Definition at line 576 of file LinearProbingHashTable.h.

◆ operator[]()

DataT & agx::LinearProbingHashTableImplementation< KeyT, DataT , HashT, AllocatorT >::operator[] ( const KeyT &  key)
inlineinherited

Return the value associated with the given key.

A new value is default created, inserted and then returned if the given key does not yet exist in the hash table.

Parameters
keyThe key to find.
Returns
The value associated with the given key. A default constructed one if no prior value existed.

Definition at line 608 of file LinearProbingHashTable.h.

◆ ptr()

const void* agx::LinearProbingHashTableImplementation< KeyT, DataT , HashT, AllocatorT >::ptr ( ) const
inlineinherited
Returns
Raw memory access to the key/value buckets.

Definition at line 729 of file LinearProbingHashTable.h.

◆ reserve()

void agx::LinearProbingHashTableImplementation< KeyT, DataT , HashT, AllocatorT >::reserve ( size_t  num_elems)
inlineinherited

Make room for this many elements in the hash table.

Definition at line 671 of file LinearProbingHashTable.h.

◆ set_get()

DataT agx::LinearProbingHashTableImplementation< KeyT, DataT , HashT, AllocatorT >::set_get ( const KeyT &  key,
const DataT &  new_value 
)
inlineinherited

Definition at line 582 of file LinearProbingHashTable.h.

◆ size()

size_t agx::LinearProbingHashTableImplementation< KeyT, DataT , HashT, AllocatorT >::size ( ) const
inlineinherited
Returns
The number of key/value pairs in the hash table.

Definition at line 398 of file LinearProbingHashTable.h.

◆ swap()

void agx::LinearProbingHashTableImplementation< KeyT, DataT , HashT, AllocatorT >::swap ( LinearProbingHashTableImplementation< KeyT, DataT, HashT, AllocatorT > &  other)
inlineinherited

Definition at line 343 of file LinearProbingHashTable.h.

◆ try_get() [1/2]

DataT * agx::LinearProbingHashTableImplementation< KeyT, DataT , HashT, AllocatorT >::try_get ( const KeyT &  k)
inlineinherited

Find the value associated with the given key.

Returns nullptr if no such value exists.

Parameters
kThe key to look for.
Returns
Pointer to the corresponding value, or nullptr.

Definition at line 476 of file LinearProbingHashTable.h.

◆ try_get() [2/2]

const DataT * agx::LinearProbingHashTableImplementation< KeyT, DataT , HashT, AllocatorT >::try_get ( const KeyT &  k) const
inlineinherited

Find the value associated with the given key.

Returns nullptr if no such value exists.

Parameters
kThe key to look for.
Returns
Pointer to the corresponding value, or nullptr.

Definition at line 491 of file LinearProbingHashTable.h.


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