openCARP
Doxygen code documentation for the open cardiac electrophysiology simulator openCARP
Classes | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends | List of all members
hashmap::unordered_set< K, OPS > Class Template Reference

Custom unordered_set implementation. More...

#include <hashmap.hpp>

Inheritance diagram for hashmap::unordered_set< K, OPS >:
Collaboration diagram for hashmap::unordered_set< K, OPS >:

Classes

class  const_iterator
 Const iterator. More...
 
struct  entry_t
 internal entry type More...
 
class  iterator
 Default iterator. More...
 

Public Member Functions

 unordered_set ()
 Empty constructor. More...
 
 unordered_set (const unordered_set &other)
 Construct from another set. More...
 
 unordered_set (unordered_set &&other)
 Construct from another set. More...
 
unordered_setoperator= (const unordered_set &other)
 
unordered_setoperator= (unordered_set &&other)
 
 unordered_set (const std::initializer_list< K > &list)
 
template<class InputIterator >
 unordered_set (InputIterator first, InputIterator last)
 
template<class InputIterator >
void insert (InputIterator first, InputIterator last)
 
std::pair< iterator, bool > insert (const K &value)
 
hm_int erase (const K &key)
 
iterator erase (iterator it)
 
hm_int count (const K &key) const
 
hm_int count (const K &key, const_iterator it) const
 
iterator find (const K &key)
 
const_iterator find (const K &key) const
 
bool operator[] (const K &key)
 
template<typename Compare = std::less<K>>
void sort (Compare comp=Compare())
 
pop ()
 
void swap (unordered_set &other)
 
bool operator== (const unordered_set &other) const
 
bool operator!= (const unordered_set &other) const
 
void reserve (size_t n)
 
size_t size () const
 
bool empty () const
 
void clear ()
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 

Protected Member Functions

hm_int do_hash (const K &key) const
 Generate a hash from a key. More...
 
void do_rehash ()
 Resize the hashtable and compute new hashes. More...
 
hm_int do_erase (hm_int index, hm_int hash)
 Remove an entry. More...
 
hm_int do_lookup (const K &key, hm_int &hash) const
 Return hash and index for a key. More...
 
hm_int do_insert (const K &value, hm_int &hash)
 Insert a pair consisting of a key and a default (empty) value. More...
 

Static Protected Member Functions

static void do_assert (bool cond)
 

Protected Attributes

std::vector< hm_inthashtable
 the hashtable More...
 
std::vector< entry_tentries
 the stored entries More...
 
OPS ops
 the hash generator More...
 

Friends

template<typename , hm_int , typename >
class idict
 

Detailed Description

template<typename K, typename OPS>
class hashmap::unordered_set< K, OPS >

Custom unordered_set implementation.

Template Parameters
KKey type.
OPSHashing and comparison class.

Definition at line 749 of file hashmap.hpp.

Constructor & Destructor Documentation

◆ unordered_set() [1/5]

template<typename K , typename OPS >
hashmap::unordered_set< K, OPS >::unordered_set ( )
inline

Empty constructor.

Definition at line 1007 of file hashmap.hpp.

◆ unordered_set() [2/5]

template<typename K , typename OPS >
hashmap::unordered_set< K, OPS >::unordered_set ( const unordered_set< K, OPS > &  other)
inline

Construct from another set.

Definition at line 1011 of file hashmap.hpp.

◆ unordered_set() [3/5]

template<typename K , typename OPS >
hashmap::unordered_set< K, OPS >::unordered_set ( unordered_set< K, OPS > &&  other)
inline

Construct from another set.

Definition at line 1018 of file hashmap.hpp.

◆ unordered_set() [4/5]

template<typename K , typename OPS >
hashmap::unordered_set< K, OPS >::unordered_set ( const std::initializer_list< K > &  list)
inline

Definition at line 1035 of file hashmap.hpp.

◆ unordered_set() [5/5]

template<typename K , typename OPS >
template<class InputIterator >
hashmap::unordered_set< K, OPS >::unordered_set ( InputIterator  first,
InputIterator  last 
)
inline

Definition at line 1042 of file hashmap.hpp.

Member Function Documentation

◆ begin() [1/2]

template<typename K , typename OPS >
iterator hashmap::unordered_set< K, OPS >::begin ( )
inline

Definition at line 1156 of file hashmap.hpp.

Here is the caller graph for this function:

◆ begin() [2/2]

template<typename K , typename OPS >
const_iterator hashmap::unordered_set< K, OPS >::begin ( ) const
inline

Definition at line 1159 of file hashmap.hpp.

◆ clear()

template<typename K , typename OPS >
void hashmap::unordered_set< K, OPS >::clear ( )
inline

Definition at line 1154 of file hashmap.hpp.

Here is the caller graph for this function:

◆ count() [1/2]

template<typename K , typename OPS >
hm_int hashmap::unordered_set< K, OPS >::count ( const K &  key) const
inline

Definition at line 1078 of file hashmap.hpp.

Here is the caller graph for this function:

◆ count() [2/2]

template<typename K , typename OPS >
hm_int hashmap::unordered_set< K, OPS >::count ( const K &  key,
const_iterator  it 
) const
inline

Definition at line 1085 of file hashmap.hpp.

◆ do_assert()

template<typename K , typename OPS >
static void hashmap::unordered_set< K, OPS >::do_assert ( bool  cond)
inlinestaticprotected

Definition at line 774 of file hashmap.hpp.

Here is the caller graph for this function:

◆ do_erase()

template<typename K , typename OPS >
hm_int hashmap::unordered_set< K, OPS >::do_erase ( hm_int  index,
hm_int  hash 
)
inlineprotected

Remove an entry.

Parameters
indexThe index in the entries vector.
hashThe hash -> index w.r.t. hashtable.
Returns

Definition at line 820 of file hashmap.hpp.

Here is the caller graph for this function:

◆ do_hash()

template<typename K , typename OPS >
hm_int hashmap::unordered_set< K, OPS >::do_hash ( const K &  key) const
inlineprotected

Generate a hash from a key.

Hash in always in the range of the current hash table size.

Parameters
keyThe key.
Returns
The hash.

Definition at line 788 of file hashmap.hpp.

Here is the caller graph for this function:

◆ do_insert()

template<typename K , typename OPS >
hm_int hashmap::unordered_set< K, OPS >::do_insert ( const K &  value,
hm_int hash 
)
inlineprotected

Insert a pair consisting of a key and a default (empty) value.

New values are always added to the end of the entries array. Their index is inserted into the hashtable at the hash index.

Parameters
[in]keyThe key.
[out]hashThe hash index.
Returns
Insert index.

Definition at line 904 of file hashmap.hpp.

Here is the caller graph for this function:

◆ do_lookup()

template<typename K , typename OPS >
hm_int hashmap::unordered_set< K, OPS >::do_lookup ( const K &  key,
hm_int hash 
) const
inlineprotected

Return hash and index for a key.

Parameters
[in]keyThe key value.
[out]hashThe hash, i.e. the hashtable index.
Returns
The enties index.

Definition at line 873 of file hashmap.hpp.

Here is the caller graph for this function:

◆ do_rehash()

template<typename K , typename OPS >
void hashmap::unordered_set< K, OPS >::do_rehash ( )
inlineprotected

Resize the hashtable and compute new hashes.

Definition at line 799 of file hashmap.hpp.

Here is the caller graph for this function:

◆ empty()

template<typename K , typename OPS >
bool hashmap::unordered_set< K, OPS >::empty ( ) const
inline

Definition at line 1153 of file hashmap.hpp.

Here is the caller graph for this function:

◆ end() [1/2]

template<typename K , typename OPS >
iterator hashmap::unordered_set< K, OPS >::end ( )
inline

Definition at line 1157 of file hashmap.hpp.

Here is the caller graph for this function:

◆ end() [2/2]

template<typename K , typename OPS >
const_iterator hashmap::unordered_set< K, OPS >::end ( ) const
inline

Definition at line 1160 of file hashmap.hpp.

◆ erase() [1/2]

template<typename K , typename OPS >
hm_int hashmap::unordered_set< K, OPS >::erase ( const K &  key)
inline

Definition at line 1064 of file hashmap.hpp.

Here is the caller graph for this function:

◆ erase() [2/2]

template<typename K , typename OPS >
iterator hashmap::unordered_set< K, OPS >::erase ( iterator  it)
inline

Definition at line 1071 of file hashmap.hpp.

◆ find() [1/2]

template<typename K , typename OPS >
iterator hashmap::unordered_set< K, OPS >::find ( const K &  key)
inline

Definition at line 1092 of file hashmap.hpp.

◆ find() [2/2]

template<typename K , typename OPS >
const_iterator hashmap::unordered_set< K, OPS >::find ( const K &  key) const
inline

Definition at line 1101 of file hashmap.hpp.

◆ insert() [1/2]

template<typename K , typename OPS >
std::pair<iterator, bool> hashmap::unordered_set< K, OPS >::insert ( const K &  value)
inline

Definition at line 1054 of file hashmap.hpp.

◆ insert() [2/2]

template<typename K , typename OPS >
template<class InputIterator >
void hashmap::unordered_set< K, OPS >::insert ( InputIterator  first,
InputIterator  last 
)
inline

Definition at line 1048 of file hashmap.hpp.

Here is the caller graph for this function:

◆ operator!=()

template<typename K , typename OPS >
bool hashmap::unordered_set< K, OPS >::operator!= ( const unordered_set< K, OPS > &  other) const
inline

Definition at line 1147 of file hashmap.hpp.

◆ operator=() [1/2]

template<typename K , typename OPS >
unordered_set& hashmap::unordered_set< K, OPS >::operator= ( const unordered_set< K, OPS > &  other)
inline

Definition at line 1023 of file hashmap.hpp.

◆ operator=() [2/2]

template<typename K , typename OPS >
unordered_set& hashmap::unordered_set< K, OPS >::operator= ( unordered_set< K, OPS > &&  other)
inline

Definition at line 1029 of file hashmap.hpp.

◆ operator==()

template<typename K , typename OPS >
bool hashmap::unordered_set< K, OPS >::operator== ( const unordered_set< K, OPS > &  other) const
inline

Definition at line 1138 of file hashmap.hpp.

Here is the caller graph for this function:

◆ operator[]()

template<typename K , typename OPS >
bool hashmap::unordered_set< K, OPS >::operator[] ( const K &  key)
inline

Definition at line 1110 of file hashmap.hpp.

◆ pop()

template<typename K , typename OPS >
K hashmap::unordered_set< K, OPS >::pop ( )
inline

Definition at line 1124 of file hashmap.hpp.

◆ reserve()

template<typename K , typename OPS >
void hashmap::unordered_set< K, OPS >::reserve ( size_t  n)
inline

Definition at line 1151 of file hashmap.hpp.

Here is the caller graph for this function:

◆ size()

template<typename K , typename OPS >
size_t hashmap::unordered_set< K, OPS >::size ( ) const
inline

Definition at line 1152 of file hashmap.hpp.

Here is the caller graph for this function:

◆ sort()

template<typename K , typename OPS >
template<typename Compare = std::less<K>>
void hashmap::unordered_set< K, OPS >::sort ( Compare  comp = Compare())
inline

Definition at line 1118 of file hashmap.hpp.

◆ swap()

template<typename K , typename OPS >
void hashmap::unordered_set< K, OPS >::swap ( unordered_set< K, OPS > &  other)
inline

Definition at line 1132 of file hashmap.hpp.

Here is the caller graph for this function:

Friends And Related Function Documentation

◆ idict

template<typename K , typename OPS >
template<typename , hm_int , typename >
friend class idict
friend

Definition at line 751 of file hashmap.hpp.

Member Data Documentation

◆ entries

template<typename K , typename OPS >
std::vector<entry_t> hashmap::unordered_set< K, OPS >::entries
protected

the stored entries

Definition at line 767 of file hashmap.hpp.

◆ hashtable

template<typename K , typename OPS >
std::vector<hm_int> hashmap::unordered_set< K, OPS >::hashtable
protected

the hashtable

Definition at line 765 of file hashmap.hpp.

◆ ops

template<typename K , typename OPS >
OPS hashmap::unordered_set< K, OPS >::ops
protected

the hash generator

Definition at line 769 of file hashmap.hpp.


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