ug4
ug::Hash< TKey, TValue > Class Template Reference

#include <hash.h>

Classes

struct  Entry
 

Public Types

typedef hash_iterator< key_t, value_t, Entryiterator
 
typedef TKey key_t
 
typedef TValue value_t
 

Public Member Functions

iterator begin (const key_t &key)
 
size_t capacity () const
 returns the capacity of the container in which key-value-pairs are stored. More...
 
void clear ()
 
bool empty () const
 
iterator end (const key_t &key)
 
void erase (const key_t &key)
 
value_tget_entry (const key_t &key)
 
const value_tget_entry (const key_t &key) const
 
bool get_entry (value_t &valOut, const key_t &key) const
 
bool has_entry (const key_t &key) const
 
 Hash ()
 
 Hash (size_t hashSize)
 
size_t hash_size () const
 
void insert (const key_t &key, const value_t &val)
 
void reserve (size_t size)
 Reserves memory for key-value-pair storage. More...
 
void resize_hash (size_t size)
 
size_t size () const
 returns the number of key-value-pairs currently stored in the hash More...
 

Private Member Functions

size_t find_entry (const key_t &key) const
 
size_t hash_index (const key_t &key) const
 
size_t invalid_index () const
 

Private Attributes

std::vector< Entrym_entries
 
size_t m_firstUnusedEntry
 
std::vector< std::pair< size_t, size_t > > m_hashList
 
size_t m_numEntries
 

Member Typedef Documentation

◆ iterator

template<class TKey , class TValue >
typedef hash_iterator<key_t, value_t, Entry> ug::Hash< TKey, TValue >::iterator

◆ key_t

template<class TKey , class TValue >
typedef TKey ug::Hash< TKey, TValue >::key_t

◆ value_t

template<class TKey , class TValue >
typedef TValue ug::Hash< TKey, TValue >::value_t

Constructor & Destructor Documentation

◆ Hash() [1/2]

template<class TKey , class TValue >
ug::Hash< TKey, TValue >::Hash

◆ Hash() [2/2]

template<class TKey , class TValue >
ug::Hash< TKey, TValue >::Hash ( size_t  hashSize)

Member Function Documentation

◆ begin()

template<class TKey , class TValue >
Hash< TKey, TValue >::iterator ug::Hash< TKey, TValue >::begin ( const key_t key)

◆ capacity()

template<class TKey , class TValue >
size_t ug::Hash< TKey, TValue >::capacity

returns the capacity of the container in which key-value-pairs are stored.

Use reserve to adjust this capacity. If the capacity would be too small to insert a new element, it will be automatically increased on element insertion.

See also
reserve

◆ clear()

template<class TKey , class TValue >
void ug::Hash< TKey, TValue >::clear

◆ empty()

template<class TKey , class TValue >
bool ug::Hash< TKey, TValue >::empty

◆ end()

template<class TKey , class TValue >
Hash< TKey, TValue >::iterator ug::Hash< TKey, TValue >::end ( const key_t key)

◆ erase()

template<class TKey , class TValue >
void ug::Hash< TKey, TValue >::erase ( const key_t key)

◆ find_entry()

template<class TKey , class TValue >
size_t ug::Hash< TKey, TValue >::find_entry ( const key_t key) const
private

◆ get_entry() [1/3]

◆ get_entry() [2/3]

template<class TKey , class TValue >
const TValue & ug::Hash< TKey, TValue >::get_entry ( const key_t key) const

References UG_THROW.

◆ get_entry() [3/3]

template<class TKey , class TValue >
bool ug::Hash< TKey, TValue >::get_entry ( value_t valOut,
const key_t key 
) const

◆ has_entry()

template<class TKey , class TValue >
bool ug::Hash< TKey, TValue >::has_entry ( const key_t key) const

◆ hash_index()

template<class TKey , class TValue >
size_t ug::Hash< TKey, TValue >::hash_index ( const key_t key) const
private

References ug::hash_key().

◆ hash_size()

template<class TKey , class TValue >
size_t ug::Hash< TKey, TValue >::hash_size

◆ insert()

◆ invalid_index()

template<class TKey , class TValue >
size_t ug::Hash< TKey, TValue >::invalid_index ( ) const
inlineprivate

◆ reserve()

template<class TKey , class TValue >
void ug::Hash< TKey, TValue >::reserve ( size_t  size)

Reserves memory for key-value-pair storage.

See also
capacity

Referenced by pcl::CollectUniqueElements(), ug::DeserializeMultiGridElements(), and ug::GenerateAlgebraIDHashList().

◆ resize_hash()

template<class TKey , class TValue >
void ug::Hash< TKey, TValue >::resize_hash ( size_t  size)

◆ size()

template<class TKey , class TValue >
size_t ug::Hash< TKey, TValue >::size ( ) const

returns the number of key-value-pairs currently stored in the hash

Member Data Documentation

◆ m_entries

template<class TKey , class TValue >
std::vector<Entry> ug::Hash< TKey, TValue >::m_entries
private

◆ m_firstUnusedEntry

template<class TKey , class TValue >
size_t ug::Hash< TKey, TValue >::m_firstUnusedEntry
private

◆ m_hashList

template<class TKey , class TValue >
std::vector<std::pair<size_t, size_t> > ug::Hash< TKey, TValue >::m_hashList
private

each entry holds a pair of indices pointing to the first and the last entry for the given hash-key.

◆ m_numEntries

template<class TKey , class TValue >
size_t ug::Hash< TKey, TValue >::m_numEntries
private

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