Initialize the Hash_set during creation
If the Hash_set is not initialized, one can not call find() on it before at least one element has been inserted into it.
This commit is contained in:
parent
b482e87f26
commit
cc08872c16
@ -28,17 +28,15 @@ class Hash_set
|
||||
public:
|
||||
enum { START_SIZE= 8 };
|
||||
/**
|
||||
Constructs an empty hash. Does not allocate memory, it is done upon
|
||||
the first insert. Thus does not cause or return errors.
|
||||
Constructs an empty unique hash.
|
||||
*/
|
||||
Hash_set(PSI_memory_key psi_key, uchar *(*K)(const T *, size_t *, my_bool),
|
||||
CHARSET_INFO *cs= &my_charset_bin)
|
||||
{
|
||||
my_hash_clear(&m_hash);
|
||||
m_hash.get_key= (my_hash_get_key)K;
|
||||
m_hash.charset= cs;
|
||||
m_hash.array.m_psi_key= psi_key;
|
||||
my_hash_init(psi_key, &m_hash, cs, START_SIZE, 0, 0, (my_hash_get_key)K, 0,
|
||||
HASH_UNIQUE);
|
||||
}
|
||||
|
||||
Hash_set(PSI_memory_key psi_key, CHARSET_INFO *charset, ulong default_array_elements,
|
||||
size_t key_offset, size_t key_length, my_hash_get_key get_key,
|
||||
void (*free_element)(void*), uint flags)
|
||||
@ -65,8 +63,6 @@ public:
|
||||
*/
|
||||
bool insert(T *value)
|
||||
{
|
||||
my_hash_init_opt(m_hash.array.m_psi_key, &m_hash, m_hash.charset,
|
||||
START_SIZE, 0, 0, m_hash.get_key, 0, HASH_UNIQUE);
|
||||
return my_hash_insert(&m_hash, reinterpret_cast<const uchar*>(value));
|
||||
}
|
||||
bool remove(T *value)
|
||||
|
Loading…
x
Reference in New Issue
Block a user