Hash set implementation backed by a template parameterized hash table.
More...
#include <tpie/hash_map.h>
Inherits tpie::linear_memory_base< hash_set< key_t, hash_t, equal_t, index_t, table_t > >.
|
static double | memory_coefficient () |
| Return the memory coefficient of the structure. More...
|
|
static double | memory_overhead () |
| Return the memory overhead of the structure. More...
|
|
static memory_size_type | memory_usage (memory_size_type size) |
| Return the number of bytes required to create a data structure supporting a given number of elements. More...
|
|
static memory_size_type | memory_fits (memory_size_type memory) |
| Return the maximum number of elements that can be contained in in the structure when it is allowed to fill a given number of bytes. More...
|
|
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 615 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 690 of file hash_map.h.
693 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 747 of file hash_map.h.
747 {
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 752 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 757 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 772 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 742 of file hash_map.h.
742 {
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 762 of file hash_map.h.
762 {
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 767 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 705 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 725 of file hash_map.h.
726 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 733 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 717 of file hash_map.h.
718 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 671 of file hash_map.h.
672 return tbl_t::memory_coefficient();
Return the maximum number of elements that can be contained in in the structure when it is allowed to fill a given number of bytes.
- Parameters
-
memory | The number of bytes the structure is allowed to occupy |
- Returns
- The number of elements that will fit in the structure
Definition at line 93 of file util.h.
94 return static_cast<memory_size_type
>(
95 floor((memory - child_t::memory_overhead()) / child_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 679 of file hash_map.h.
680 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.
Return the number of bytes required to create a data structure supporting a given number of elements.
- Parameters
-
size | The number of elements to support |
- Returns
- The amount of memory required in bytes
Definition at line 81 of file util.h.
82 return static_cast<memory_size_type
>(
83 floor(static_cast<double>(size) * child_t::memory_coefficient() + child_t::memory_overhead()));
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 699 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 777 of file hash_map.h.
The documentation for this class was generated from the following file: