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
 
struct  entry_t
 internal entry type More...
 
class  iterator
 

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 705 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 921 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 925 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 932 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 949 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 956 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 1070 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 1073 of file hashmap.hpp.

◆ clear()

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

Definition at line 1068 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 992 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 999 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 730 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 776 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 744 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 860 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 829 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 755 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 1067 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 1071 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 1074 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 978 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 985 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 1006 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 1015 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 968 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 962 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 1061 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 937 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 943 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 1052 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 1024 of file hashmap.hpp.

◆ pop()

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

Definition at line 1038 of file hashmap.hpp.

◆ reserve()

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

Definition at line 1065 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 1066 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 1032 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 1046 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 707 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 723 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 721 of file hashmap.hpp.

◆ ops

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

the hash generator

Definition at line 725 of file hashmap.hpp.


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