Hash set implementation backed by a template parameterized hash table.
More...
#include <tpie/hash_map.h>
template<typename key_t, typename hash_t = hash<key_t>, typename equal_t = std::equal_to<key_t>, typename index_t = size_t, template< typename, typename, typename, typename > class table_t = linear_probing_hash_table>
class tpie::hash_set< key_t, hash_t, equal_t, index_t, table_t >
Hash set implementation backed by a template parameterized hash table.
- Template Parameters
-
key_t | Type of keys to store. |
hash_t | (Optional) Hash function to use. |
equal_t | (Optional) Equality predicate. |
index_t | (Optional) Index type into bucket array. Always size_t. |
table_t | (Optional) Hash table implementation. |
Definition at line 678 of file hash_map.h.
template<typename key_t , typename hash_t = hash<key_t>, typename equal_t = std::equal_to<key_t>, typename index_t = size_t, template< typename, typename, typename, typename > class table_t = linear_probing_hash_table>
template<typename key_t , typename hash_t = hash<key_t>, typename equal_t = std::equal_to<key_t>, typename index_t = size_t, template< typename, typename, typename, typename > class table_t = linear_probing_hash_table>
tpie::hash_set< key_t, hash_t, equal_t, index_t, table_t >::hash_set |
( |
size_t |
size = 0 , |
|
|
const hash_t & |
hash = hash_t() , |
|
|
const equal_t & |
equal = equal_t() , |
|
|
value_t |
u = default_unused<value_t>::v() |
|
) |
| |
|
inline |
Construct hash set.
- Parameters
-
size | Number of buckets in initial hash map. |
hash | Hash function to use. |
equal | Equality predicate to use. |
u | Value to use for unused bucket entries. |
Definition at line 753 of file hash_map.h.
756 tbl(
size, u, hash, equal) {}
size_t size() const
Return number of keys in set.
template<typename key_t , typename hash_t = hash<key_t>, typename equal_t = std::equal_to<key_t>, typename index_t = size_t, template< typename, typename, typename, typename > class table_t = linear_probing_hash_table>
Return iterator to beginning of set.
Definition at line 810 of file hash_map.h.
810 {
return iterator(tbl, tbl.begin());}
template<typename key_t , typename hash_t = hash<key_t>, typename equal_t = std::equal_to<key_t>, typename index_t = size_t, template< typename, typename, typename, typename > class table_t = linear_probing_hash_table>
Return const iterator to beginning of set.
Definition at line 815 of file hash_map.h.
iter_base< const tbl_t > const_iterator
Const iterator type.
template<typename key_t , typename hash_t = hash<key_t>, typename equal_t = std::equal_to<key_t>, typename index_t = size_t, template< typename, typename, typename, typename > class table_t = linear_probing_hash_table>
Return const iterator to beginning of set.
Definition at line 820 of file hash_map.h.
iter_base< const tbl_t > const_iterator
Const iterator type.
template<typename key_t , typename hash_t = hash<key_t>, typename equal_t = std::equal_to<key_t>, typename index_t = size_t, template< typename, typename, typename, typename > class table_t = linear_probing_hash_table>
Return const iterator to end of set.
Definition at line 835 of file hash_map.h.
iter_base< const tbl_t > const_iterator
Const iterator type.
template<typename key_t , typename hash_t = hash<key_t>, typename equal_t = std::equal_to<key_t>, typename index_t = size_t, template< typename, typename, typename, typename > class table_t = linear_probing_hash_table>
void tpie::hash_set< key_t, hash_t, equal_t, index_t, table_t >::clear |
( |
| ) |
const |
|
inline |
template<typename key_t , typename hash_t = hash<key_t>, typename equal_t = std::equal_to<key_t>, typename index_t = size_t, template< typename, typename, typename, typename > class table_t = linear_probing_hash_table>
bool tpie::hash_set< key_t, hash_t, equal_t, index_t, table_t >::contains |
( |
const key_t & |
key | ) |
const |
|
inline |
Search for key.
Returns true if the given key exists in the hash set.
- Parameters
-
Definition at line 805 of file hash_map.h.
805 {
return tbl.find(key) != tbl.end();}
template<typename key_t , typename hash_t = hash<key_t>, typename equal_t = std::equal_to<key_t>, typename index_t = size_t, template< typename, typename, typename, typename > class table_t = linear_probing_hash_table>
Return iterator to end of set.
Definition at line 825 of file hash_map.h.
825 {
return iterator(tbl, tbl.end());}
template<typename key_t , typename hash_t = hash<key_t>, typename equal_t = std::equal_to<key_t>, typename index_t = size_t, template< typename, typename, typename, typename > class table_t = linear_probing_hash_table>
Return const iterator to end of set.
Definition at line 830 of file hash_map.h.
iter_base< const tbl_t > const_iterator
Const iterator type.
template<typename key_t , typename hash_t = hash<key_t>, typename equal_t = std::equal_to<key_t>, typename index_t = size_t, template< typename, typename, typename, typename > class table_t = linear_probing_hash_table>
void tpie::hash_set< key_t, hash_t, equal_t, index_t, table_t >::erase |
( |
const key_t & |
key | ) |
|
|
inline |
Erase entry from hash set by key.
- Parameters
-
key | Key of entry to remove. |
Definition at line 768 of file hash_map.h.
template<typename key_t , typename hash_t = hash<key_t>, typename equal_t = std::equal_to<key_t>, typename index_t = size_t, template< typename, typename, typename, typename > class table_t = linear_probing_hash_table>
template<typename key_t , typename hash_t = hash<key_t>, typename equal_t = std::equal_to<key_t>, typename index_t = size_t, template< typename, typename, typename, typename > class table_t = linear_probing_hash_table>
Get iterator to element.
- Parameters
-
Definition at line 788 of file hash_map.h.
789 return iterator(tbl, tbl.find(key));
template<typename key_t , typename hash_t = hash<key_t>, typename equal_t = std::equal_to<key_t>, typename index_t = size_t, template< typename, typename, typename, typename > class table_t = linear_probing_hash_table>
Get const iterator to element.
- Parameters
-
Definition at line 796 of file hash_map.h.
iter_base< const tbl_t > const_iterator
Const iterator type.
template<typename key_t , typename hash_t = hash<key_t>, typename equal_t = std::equal_to<key_t>, typename index_t = size_t, template< typename, typename, typename, typename > class table_t = linear_probing_hash_table>
bool tpie::hash_set< key_t, hash_t, equal_t, index_t, table_t >::insert |
( |
const key_t & |
key | ) |
|
|
inline |
Insert key into set.
- Parameters
-
Definition at line 780 of file hash_map.h.
781 return tbl.insert(key).second;
template<typename key_t , typename hash_t = hash<key_t>, typename equal_t = std::equal_to<key_t>, typename index_t = size_t, template< typename, typename, typename, typename > class table_t = linear_probing_hash_table>
static double tpie::hash_set< key_t, hash_t, equal_t, index_t, table_t >::memory_coefficient |
( |
| ) |
|
|
inlinestatic |
Return the memory coefficient of the structure.
Allocating a structure with n elements will use at most bytes. This does not include memory overhead incurred if the structure is allocated using new.
- Returns
- The memory coefficient of the structure.
Definition at line 734 of file hash_map.h.
735 return tbl_t::memory_coefficient();
template<typename key_t , typename hash_t = hash<key_t>, typename equal_t = std::equal_to<key_t>, typename index_t = size_t, template< typename, typename, typename, typename > class table_t = linear_probing_hash_table>
static double tpie::hash_set< key_t, hash_t, equal_t, index_t, table_t >::memory_overhead |
( |
| ) |
|
|
inlinestatic |
Return the memory overhead of the structure.
- See also
- memory_coefficient()
- Returns
- The memory overhead.
Definition at line 742 of file hash_map.h.
743 return tbl_t::memory_overhead() -
sizeof(tbl_t) +
sizeof(
hash_set);
hash_set(size_t size=0, const hash_t &hash=hash_t(), const equal_t &equal=equal_t(), value_t u=default_unused< value_t >::v())
Construct hash set.
template<typename key_t , typename hash_t = hash<key_t>, typename equal_t = std::equal_to<key_t>, typename index_t = size_t, template< typename, typename, typename, typename > class table_t = linear_probing_hash_table>
void tpie::hash_set< key_t, hash_t, equal_t, index_t, table_t >::resize |
( |
size_t |
size | ) |
|
|
inline |
Resize hash set to given size and remove all entries.
- Parameters
-
size | New size of hash set. |
Definition at line 762 of file hash_map.h.
size_t size() const
Return number of keys in set.
template<typename key_t , typename hash_t = hash<key_t>, typename equal_t = std::equal_to<key_t>, typename index_t = size_t, template< typename, typename, typename, typename > class table_t = linear_probing_hash_table>
size_t tpie::hash_set< key_t, hash_t, equal_t, index_t, table_t >::size |
( |
| ) |
const |
|
inline |
Return number of keys in set.
Definition at line 840 of file hash_map.h.
The documentation for this class was generated from the following file: