Documentation for module qs_nl_hash_table_types

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.

source: qs_nl_hash_table_types.F
Loading...

public Types:

nl_hash_table_obj
the object container which allows for the creation of an array of pointers to nl_hash_table objects

public Subroutines/Functions:

SUBROUTINE RECURSIVE
nl_hash_table_add (hash_table, key, val)
Add element to a hash table, auto resize if necessary
Creates and initialises an empty nl_hash_table object
Retrieve value from a hash table given a specified index
Initialises a nl_hash_table object
releases the hash table. Note that deallocating tasks stored in the table is the responsibility of the caller
outputs the current information about the table

public Types:

TYPE :: nl_hash_table_obj

the object container which allows for the creation of an array of pointers to nl_hash_table objects


POINTER, PRIVATE :: obj => NULL() pointer to the nl_hash_table object

RECURSIVE SUBROUTINEnl_hash_table_add(hash_table, key, val)

Add element to a hash table, auto resize if necessary

Arguments:
INTENT(inout)
:: hash_table the nl_hash_table object
INTEGER(int_8),
INTENT(in)
:: key key of the element
INTENT(in),
POINTER
:: val value of the element

SUBROUTINEnl_hash_table_create(hash_table, nmax)

Creates and initialises an empty nl_hash_table object

Arguments:
INTENT(inout)
:: hash_table the nl_hash_table object, its content must be NULL and cannot be UNDEFINED
INTEGER,
INTENT(in),
OPTIONAL
:: nmax total size of the table, optional. If absent default size is 1.

SUBROUTINEnl_hash_table_get_from_index(hash_table, idx, val)

Retrieve value from a hash table given a specified index

Arguments:
INTENT(in)
:: hash_table the nl_hash_table object
INTEGER,
INTENT(in)
:: idx the index to retrieve the data for
INTENT(out),
POINTER
:: val output value, might be unassociated if there is no data with that index

SUBROUTINEnl_hash_table_is_null(hash_table, key, is_null)

Initialises a nl_hash_table object

Arguments:
INTENT(in)
:: hash_table the nl_hash_table object, its content must be NULL and cannot be UNDEFINED
INTEGER,
INTENT(in)
:: key ...
LOGICAL,
INTENT(out)
:: is_null ...

SUBROUTINEnl_hash_table_release(hash_table)

releases the hash table. Note that deallocating tasks stored in the table is the responsibility of the caller

Arguments:
INTENT(inout)
:: hash_table the nl_hash_table object in question

SUBROUTINEnl_hash_table_status(hash_table, nelements, nmax, prime)

outputs the current information about the table

Arguments:
INTENT(inout)
:: hash_table the nl_hash_table object in question
INTEGER,
INTENT(out),
OPTIONAL
:: nelements number of non-empty slots in the table
INTEGER,
INTENT(out),
OPTIONAL
:: nmax maximum number of slots in the table
INTEGER,
INTENT(out),
OPTIONAL
:: prime the prime used in the hash function

private Parameters/Types:

private Types:

TYPE :: nl_hash_table_data

data defining a hash table using open addressing for collision resolvation. Uses simple entry structure to be memory efficient as well as small overhead


INTEGER
:: id_nr unique id for the object
INTEGER
:: ref_count reference counter for the object
DIMENSION(:), POINTER :: table => NULL() hash table data area
INTEGER
:: nelements number of non-empty slots in table
INTEGER
:: nmax max number of slots in table
INTEGER
:: prime prime number used in the hash function

TYPE :: nl_hash_table_element

hash table entry data type


INTEGER(int_8)
:: key key of the entry
POINTER :: val value of the entry