![]() |
(git:b77b4be)
|
A simple hash table of integer keys, using hash function: H(k) = (k*p) mod n + 1 where: k = key p = a prime number >= n n = size of the hash table And collision resolvation is done by open addressing with linear probing. More...
Data Types | |
type | nl_hash_table_obj |
the object container which allows for the creation of an array of pointers to nl_hash_table objects More... | |
Functions/Subroutines | |
recursive subroutine, public | nl_hash_table_add (hash_table, key, val) |
Add element to a hash table, auto resize if necessary. | |
subroutine, public | nl_hash_table_create (hash_table, nmax) |
Creates and initialises an empty nl_hash_table object. | |
subroutine, public | nl_hash_table_get_from_index (hash_table, idx, val) |
Retrieve value from a hash table given a specified index. | |
subroutine, public | nl_hash_table_is_null (hash_table, key, is_null) |
Initialises a nl_hash_table object. | |
subroutine, public | nl_hash_table_release (hash_table) |
releases the hash table. Note that deallocating tasks stored in the table is the responsibility of the caller | |
subroutine, public | nl_hash_table_status (hash_table, nelements, nmax, prime) |
outputs the current information about the table | |
A simple hash table of integer keys, using hash function: H(k) = (k*p) mod n + 1 where: k = key p = a prime number >= n n = size of the hash table And collision resolvation is done by open addressing with linear probing.
The table consists of an array of (key,val) pairs, and there are no intermediate buckets. For every new entry (k,v): We first look up slot H(k), and if it already contains an entry, then move to the next empty slot using a predefined linear probing sequence (e.g. iterate from slots H(k) to n, and then 1 to H(k)-1). When we look up, we use the same probing sequence.
Derived from qs_fb_hash_table_types.F (Mark Tucker, Jun 2016)
recursive subroutine, public qs_nl_hash_table_types::nl_hash_table_add | ( | type(nl_hash_table_obj), intent(inout) | hash_table, |
integer(kind=int_8), intent(in) | key, | ||
type(neighbor_list_task_type), intent(in), pointer | val | ||
) |
Add element to a hash table, auto resize if necessary.
hash_table | : the nl_hash_table object |
key | : key of the element |
val | : value of the element |
Definition at line 103 of file qs_nl_hash_table_types.F.
subroutine, public qs_nl_hash_table_types::nl_hash_table_create | ( | type(nl_hash_table_obj), intent(inout) | hash_table, |
integer, intent(in), optional | nmax | ||
) |
Creates and initialises an empty nl_hash_table object.
hash_table | : the nl_hash_table object, its content must be NULL and cannot be UNDEFINED |
nmax | : total size of the table, optional. If absent default size is 1. |
Definition at line 143 of file qs_nl_hash_table_types.F.
subroutine, public qs_nl_hash_table_types::nl_hash_table_get_from_index | ( | type(nl_hash_table_obj), intent(in) | hash_table, |
integer, intent(in) | idx, | ||
type(neighbor_list_task_type), intent(out), pointer | val | ||
) |
Retrieve value from a hash table given a specified index.
hash_table | : the nl_hash_table object |
idx | : the index to retrieve the data for |
val | : output value, might be unassociated if there is no data with that index |
Definition at line 169 of file qs_nl_hash_table_types.F.
subroutine, public qs_nl_hash_table_types::nl_hash_table_is_null | ( | type(nl_hash_table_obj), intent(in) | hash_table, |
integer, intent(in) | key, | ||
logical, intent(out) | is_null | ||
) |
Initialises a nl_hash_table object.
hash_table | : the nl_hash_table object, its content must be NULL and cannot be UNDEFINED |
key | ... |
is_null | ... |
Definition at line 248 of file qs_nl_hash_table_types.F.
subroutine, public qs_nl_hash_table_types::nl_hash_table_release | ( | type(nl_hash_table_obj), intent(inout) | hash_table | ) |
releases the hash table. Note that deallocating tasks stored in the table is the responsibility of the caller
hash_table | : the nl_hash_table object in question |
Definition at line 309 of file qs_nl_hash_table_types.F.
subroutine, public qs_nl_hash_table_types::nl_hash_table_status | ( | type(nl_hash_table_obj), intent(inout) | hash_table, |
integer, intent(out), optional | nelements, | ||
integer, intent(out), optional | nmax, | ||
integer, intent(out), optional | prime | ||
) |
outputs the current information about the table
hash_table | : the nl_hash_table object in question |
nelements | : number of non-empty slots in the table |
nmax | : maximum number of slots in the table |
prime | : the prime used in the hash function |
Definition at line 329 of file qs_nl_hash_table_types.F.