26 #ifndef HYPERTABLE_CSTR_HASHMAP_H
27 #define HYPERTABLE_CSTR_HASHMAP_H
31 #include <unordered_map>
43 template <
typename DataT,
class TraitsT = CstrHashTraits<> >
44 class CstrHashMap :
public std::unordered_map<const char *, DataT,
45 typename TraitsT::hasher,
46 typename TraitsT::key_equal> {
48 typedef std::unordered_map<
const char *, DataT,
typename TraitsT::hasher,
49 typename TraitsT::key_equal>
Base;
55 typedef std::pair<iterator, bool>
InsRet;
76 InsRet
insert(
const char *key,
const DataT &data) {
103 char *keycopy = m_alloc.dup(key);
104 const_cast<key_type &
>(rv.first->first) = keycopy;
void clear()
Clears the map and deletes all elements.
key_allocator & key_alloc()
Returns the key allocator; required for testing.
std::pair< iterator, bool > InsRet
CstrHashMap()
Default constructor creates an empty map.
A hash map for storing and lookup char * strings efficiently.
Base::value_type value_type
TraitsT::key_allocator key_allocator
Helper structures for CstrHashMap.
InsRet insert(const char *key, const DataT &data)
Inserts a new string/data pair in the map.
CstrHashMap(size_t n_buckets)
Overloaded Constructor creates an empty map with a specified number of buckets.
std::unordered_map< const char *, DataT, typename TraitsT::hasher, typename TraitsT::key_equal > Base
InsRet insert_key(const char *key, InsRet rv)
Helper function to insert a string; if the string already exists then a duplicate of the string is cr...
key_allocator m_alloc
The key_allocator - i.e.