AGXDynamics  2.31.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
agx::LinearProbingHashTable< agx::ref_ptr< KeyT >, DataT, HashT, AllocatorT > Class Template Reference

#include <LinearProbingHashTable.h>

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

Public Types

using bucket_type = PairT
 
enum  ClearPolicy
 
typedef
Implementation::const_iterator 
const_iterator
 
using const_reference = const PairT &
 
typedef
LinearProbingHashTableImplementation
< agx::ref_ptr< KeyT >, DataT,
HashT, AllocatorT > 
Implementation
 
typedef Implementation::iterator iterator
 
using key_type = agx::ref_ptr< 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 agx::ref_ptr< KeyT > &k) const
 Check if the hash table contains a key/value pair for the given key. More...
 
bool contains (const KeyT *key) const
 
size_t count (const agx::ref_ptr< 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 agx::ref_ptr< KeyT > &key)
 Erase an element from the hash table. More...
 
iterator erase (iterator it)
 Erase an element from the hash table. More...
 
bool erase (const KeyT *key)
 
iterator find (const agx::ref_ptr< KeyT > &key)
 Find a key/value pair in the hash table given a key. More...
 
const_iterator find (const agx::ref_ptr< KeyT > &key) const
 Find a key/value pair in the hash table given a key. More...
 
iterator find (const KeyT *key)
 
const_iterator find (const KeyT *key) const
 
const DataT get_or_return_default (const agx::ref_ptr< KeyT > &k) const
 
insert_iterator insert (const agx::ref_ptr< KeyT > &key, const DataTvalue)
 Insert a key/value pair into the hash table. More...
 
insert_iterator insert (const std::pair< agx::ref_ptr< KeyT >, DataT > &p)
 
void insert (const_iterator begin, const_iterator end)
 Insert all elements in the given range. More...
 
void insert_unique (agx::ref_ptr< 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< agx::ref_ptr< KeyT >, DataT > &&p)
 
DataT & operator[] (const agx::ref_ptr< 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 agx::ref_ptr< KeyT > &key, const DataT &new_value)
 
size_t size () const
 
void swap (LinearProbingHashTableImplementation &other)
 
DataT * try_get (const agx::ref_ptr< KeyT > &k)
 Find the value associated with the given key. More...
 
const DataT * try_get (const agx::ref_ptr< 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, typename AllocatorT>
class agx::LinearProbingHashTable< agx::ref_ptr< KeyT >, DataT, HashT, AllocatorT >

Definition at line 884 of file LinearProbingHashTable.h.

Member Typedef Documentation

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

Definition at line 64 of file LinearProbingHashTable.h.

template<typename KeyT , typename DataT , typename HashT , typename AllocatorT >
typedef Implementation::const_iterator agx::LinearProbingHashTable< agx::ref_ptr< KeyT >, DataT, HashT, AllocatorT >::const_iterator

Definition at line 889 of file LinearProbingHashTable.h.

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

Definition at line 66 of file LinearProbingHashTable.h.

template<typename KeyT , typename DataT , typename HashT , typename AllocatorT >
typedef LinearProbingHashTableImplementation<agx::ref_ptr<KeyT>, DataT, HashT, AllocatorT> agx::LinearProbingHashTable< agx::ref_ptr< KeyT >, DataT, HashT, AllocatorT >::Implementation

Definition at line 887 of file LinearProbingHashTable.h.

template<typename KeyT , typename DataT , typename HashT , typename AllocatorT >
typedef Implementation::iterator agx::LinearProbingHashTable< agx::ref_ptr< KeyT >, DataT, HashT, AllocatorT >::iterator

Definition at line 888 of file LinearProbingHashTable.h.

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

Definition at line 61 of file LinearProbingHashTable.h.

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

Definition at line 65 of file LinearProbingHashTable.h.

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

Definition at line 62 of file LinearProbingHashTable.h.

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

Definition at line 63 of file LinearProbingHashTable.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

template<typename KeyT , typename DataT , typename HashT , typename AllocatorT >
agx::LinearProbingHashTable< agx::ref_ptr< KeyT >, DataT, HashT, AllocatorT >::LinearProbingHashTable ( )
inline

Definition at line 891 of file LinearProbingHashTable.h.

Member Function Documentation

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

Iterator to first element in hash table.

Definition at line 360 of file LinearProbingHashTable.h.

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

Iterator to first element in hash table.

Definition at line 372 of file LinearProbingHashTable.h.

size_t agx::LinearProbingHashTableImplementation< agx::ref_ptr< 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.

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

Remove all elements, keeping full capacity.

Definition at line 656 of file LinearProbingHashTable.h.

bool agx::LinearProbingHashTableImplementation< agx::ref_ptr< KeyT > , DataT , HashT, AllocatorT >::contains ( const agx::ref_ptr< 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.

template<typename KeyT , typename DataT , typename HashT , typename AllocatorT >
bool agx::LinearProbingHashTable< agx::ref_ptr< KeyT >, DataT, HashT, AllocatorT >::contains ( const KeyT *  key) const
inline
size_t agx::LinearProbingHashTableImplementation< agx::ref_ptr< KeyT > , DataT , HashT, AllocatorT >::count ( const agx::ref_ptr< 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.

bool agx::LinearProbingHashTableImplementation< agx::ref_ptr< 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.

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

Iterator marking end of hash table.

Definition at line 385 of file LinearProbingHashTable.h.

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

Iterator marking end of hash table.

Definition at line 392 of file LinearProbingHashTable.h.

bool agx::LinearProbingHashTableImplementation< agx::ref_ptr< KeyT > , DataT , HashT, AllocatorT >::erase ( const agx::ref_ptr< 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.

iterator agx::LinearProbingHashTableImplementation< agx::ref_ptr< 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.

template<typename KeyT , typename DataT , typename HashT , typename AllocatorT >
bool agx::LinearProbingHashTable< agx::ref_ptr< KeyT >, DataT, HashT, AllocatorT >::erase ( const KeyT *  key)
inline
void agx::LinearProbingHashTableImplementation< agx::ref_ptr< KeyT > , DataT , HashT, AllocatorT >::erase_bucket ( size_t  bucket)
inlineprotectedinherited

Definition at line 754 of file LinearProbingHashTable.h.

iterator agx::LinearProbingHashTableImplementation< agx::ref_ptr< KeyT > , DataT , HashT, AllocatorT >::find ( const agx::ref_ptr< 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.

const_iterator agx::LinearProbingHashTableImplementation< agx::ref_ptr< KeyT > , DataT , HashT, AllocatorT >::find ( const agx::ref_ptr< 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.

template<typename KeyT , typename DataT , typename HashT , typename AllocatorT >
iterator agx::LinearProbingHashTable< agx::ref_ptr< KeyT >, DataT, HashT, AllocatorT >::find ( const KeyT *  key)
inline
template<typename KeyT , typename DataT , typename HashT , typename AllocatorT >
const_iterator agx::LinearProbingHashTable< agx::ref_ptr< KeyT >, DataT, HashT, AllocatorT >::find ( const KeyT *  key) const
inline
size_t agx::LinearProbingHashTableImplementation< agx::ref_ptr< KeyT > , DataT , HashT, AllocatorT >::find_filled_bucket ( const T2 &  key) const
inlineprotectedinherited

Definition at line 737 of file LinearProbingHashTable.h.

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

Definition at line 502 of file LinearProbingHashTable.h.

insert_iterator agx::LinearProbingHashTableImplementation< agx::ref_ptr< KeyT > , DataT , HashT, AllocatorT >::insert ( const agx::ref_ptr< 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_iterator agx::LinearProbingHashTableImplementation< agx::ref_ptr< KeyT > , DataT , HashT, AllocatorT >::insert ( const std::pair< agx::ref_ptr< KeyT > , DataT > &  p)
inlineinherited

Definition at line 540 of file LinearProbingHashTable.h.

void agx::LinearProbingHashTableImplementation< agx::ref_ptr< 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.

void agx::LinearProbingHashTableImplementation< agx::ref_ptr< KeyT > , DataT , HashT, AllocatorT >::insert_unique ( agx::ref_ptr< 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.

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

Definition at line 576 of file LinearProbingHashTable.h.

DataT & agx::LinearProbingHashTableImplementation< agx::ref_ptr< KeyT > , DataT , HashT, AllocatorT >::operator[] ( const agx::ref_ptr< 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.

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

Definition at line 729 of file LinearProbingHashTable.h.

void agx::LinearProbingHashTableImplementation< agx::ref_ptr< 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.

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

Definition at line 582 of file LinearProbingHashTable.h.

size_t agx::LinearProbingHashTableImplementation< agx::ref_ptr< 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.

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

Definition at line 343 of file LinearProbingHashTable.h.

DataT * agx::LinearProbingHashTableImplementation< agx::ref_ptr< KeyT > , DataT , HashT, AllocatorT >::try_get ( const agx::ref_ptr< 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.

const DataT * agx::LinearProbingHashTableImplementation< agx::ref_ptr< KeyT > , DataT , HashT, AllocatorT >::try_get ( const agx::ref_ptr< 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: