#include <gim_hash_table.h>
Public Member Functions | |
gim_hash_table (GUINT reserve_size=GIM_DEFAULT_HASH_TABLE_SIZE, GUINT node_size=GIM_DEFAULT_HASH_TABLE_NODE_SIZE, GUINT min_hash_table_size=GIM_INVALID_HASH) | |
~gim_hash_table () | |
bool | is_hash_table () |
bool | is_sorted () |
bool | sort () |
bool | switch_to_hashtable () |
bool | switch_to_sorted_array () |
bool | check_for_switching_to_hashtable () |
If the container reaches the. | |
void | set_sorted (bool value) |
GUINT | size () const |
Retrieves the amount of keys. | |
GUINT | get_key (GUINT index) const |
Retrieves the hash key. | |
T * | get_value_by_index (GUINT index) |
Retrieves the value by index. | |
const T & | operator[] (GUINT index) const |
T & | operator[] (GUINT index) |
GUINT | find (GUINT hashkey) |
Finds the index of the element with the key. | |
T * | get_value (GUINT hashkey) |
Retrieves the value associated with the index. | |
bool | erase_by_index (GUINT index) |
bool | erase_by_index_unsorted (GUINT index) |
bool | erase_by_key (GUINT hashkey) |
void | clear () |
GUINT | insert (GUINT hashkey, const T &element) |
Insert an element into the hash. | |
GUINT | insert_override (GUINT hashkey, const T &element) |
Insert an element into the hash, and could overrite an existing object with the same hash. | |
GUINT | insert_unsorted (GUINT hashkey, const T &element) |
Insert an element into the hash,But if this container is a sorted array, this inserts it unsorted. | |
Protected Types | |
typedef GIM_HASH_TABLE_NODE< T > | _node_type |
Protected Member Functions | |
GUINT | _find_cell (GUINT hashkey) |
Returns the cell index. | |
GUINT | _find_avaliable_cell (GUINT hashkey) |
Find the avaliable cell for the hashkey, and return an existing cell if it has the same hash key. | |
void | _reserve_table_memory (GUINT newtablesize) |
reserves the memory for the hash table. | |
void | _invalidate_keys () |
void | _clear_table_memory () |
Clear all memory for the hash table. | |
void | _rehash () |
Invalidates the keys (Assigning GIM_INVALID_HASH to all) Reorders the hash keys. | |
void | _resize_table (GUINT newsize) |
Resize hash table indices. | |
void | _destroy () |
Destroy hash table memory. | |
GUINT | _assign_hash_table_cell (GUINT hashkey) |
Finds an avaliable hash table cell, and resizes the table if there isn't space. | |
bool | _erase_by_index_hash_table (GUINT index) |
erase by index in hash table | |
bool | _erase_hash_table (GUINT hashkey) |
erase by key in hash table | |
GUINT | _insert_hash_table (GUINT hashkey, const T &value) |
insert an element in hash table | |
GUINT | _insert_hash_table_replace (GUINT hashkey, const T &value) |
insert an element in hash table. | |
bool | _erase_sorted (GUINT index) |
bool | _erase_unsorted (GUINT index) |
faster, but unsorted | |
void | _insert_in_pos (GUINT hashkey, const T &value, GUINT pos) |
Insert in position ordered. | |
GUINT | _insert_sorted (GUINT hashkey, const T &value) |
Insert an element in an ordered array. | |
GUINT | _insert_sorted_replace (GUINT hashkey, const T &value) |
GUINT | _insert_unsorted (GUINT hashkey, const T &value) |
Fast insertion in m_nodes array. | |
Protected Attributes | |
gim_array< _node_type > | m_nodes |
The nodes. | |
bool | m_sorted |
GUINT * | m_hash_table |
GUINT | m_table_size |
GUINT | m_node_size |
GUINT | m_min_hash_table_size |
A memory aligned compact hash table that coud be treated as an array. It could be a simple sorted array without the overhead of the hash key bucked, or could be a formely hash table with an array of keys. You can use switch_to_hashtable() and switch_to_sorted_array for saving space or increase speed.
typedef GIM_HASH_TABLE_NODE<T> gim_hash_table< T >::_node_type [protected] |
gim_hash_table< T >::gim_hash_table | ( | GUINT | reserve_size = GIM_DEFAULT_HASH_TABLE_SIZE , |
|
GUINT | node_size = GIM_DEFAULT_HASH_TABLE_NODE_SIZE , |
|||
GUINT | min_hash_table_size = GIM_INVALID_HASH | |||
) | [inline] |
if node_size = 0, then this container becomes a simple sorted array allocator. reserve_size is used for reserve memory in m_nodes. When the array size reaches the size equivalent to 'min_hash_table_size', then it becomes a hash table by calling check_for_switching_to_hashtable. If node_size != 0, then this container becomes a hash table for ever
gim_hash_table< T >::~gim_hash_table | ( | ) | [inline] |
bool gim_hash_table< T >::is_hash_table | ( | ) | [inline] |
bool gim_hash_table< T >::is_sorted | ( | ) | [inline] |
bool gim_hash_table< T >::sort | ( | ) | [inline] |
bool gim_hash_table< T >::switch_to_hashtable | ( | ) | [inline] |
bool gim_hash_table< T >::switch_to_sorted_array | ( | ) | [inline] |
bool gim_hash_table< T >::check_for_switching_to_hashtable | ( | ) | [inline] |
If the container reaches the.
void gim_hash_table< T >::set_sorted | ( | bool | value | ) | [inline] |
GUINT gim_hash_table< T >::size | ( | ) | const [inline] |
Retrieves the amount of keys.
GUINT gim_hash_table< T >::get_key | ( | GUINT | index | ) | const [inline] |
Retrieves the hash key.
T* gim_hash_table< T >::get_value_by_index | ( | GUINT | index | ) | [inline] |
Retrieves the value by index.
const T& gim_hash_table< T >::operator[] | ( | GUINT | index | ) | const [inline] |
T& gim_hash_table< T >::operator[] | ( | GUINT | index | ) | [inline] |
GUINT gim_hash_table< T >::find | ( | GUINT | hashkey | ) | [inline] |
Finds the index of the element with the key.
T* gim_hash_table< T >::get_value | ( | GUINT | hashkey | ) | [inline] |
Retrieves the value associated with the index.
bool gim_hash_table< T >::erase_by_index | ( | GUINT | index | ) | [inline] |
bool gim_hash_table< T >::erase_by_index_unsorted | ( | GUINT | index | ) | [inline] |
bool gim_hash_table< T >::erase_by_key | ( | GUINT | hashkey | ) | [inline] |
void gim_hash_table< T >::clear | ( | ) | [inline] |
GUINT gim_hash_table< T >::insert | ( | GUINT | hashkey, | |
const T & | element | |||
) | [inline] |
Insert an element into the hash.
GUINT gim_hash_table< T >::insert_override | ( | GUINT | hashkey, | |
const T & | element | |||
) | [inline] |
Insert an element into the hash, and could overrite an existing object with the same hash.
GUINT gim_hash_table< T >::insert_unsorted | ( | GUINT | hashkey, | |
const T & | element | |||
) | [inline] |
Insert an element into the hash,But if this container is a sorted array, this inserts it unsorted.
gim_array< _node_type > gim_hash_table< T >::m_nodes [protected] |
The nodes.
bool gim_hash_table< T >::m_sorted [protected] |