Documentation for module qs_fb_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_fb_hash_table_types.F
Loading...

public Types:

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

public Subroutines/Functions:

SUBROUTINE RECURSIVE
fb_hash_table_add (hash_table, key, val)
Add element to a hash table, auto resize if necessary
Creates and initialises an empty fb_hash_table object
Retrieve value from a key from a hash table
FUNCTION
LOGICAL PURE
fb_hash_table_has_data (hash_table)
check if the object has data associated to it
Nullifies a fb_hash_table object
releases given object

public Types:

TYPE :: fb_hash_table_obj

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


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

RECURSIVE SUBROUTINEfb_hash_table_add(hash_table, key, val)

Add element to a hash table, auto resize if necessary

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

SUBROUTINEfb_hash_table_create(hash_table, nmax)

Creates and initialises an empty fb_hash_table object

Arguments:
INTENT(inout)
:: hash_table the fb_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.

SUBROUTINEfb_hash_table_get(hash_table, key, val, found)

Retrieve value from a key from a hash table

Arguments:
INTENT(in)
:: hash_table the fb_hash_table object
INTEGER(int_8),
INTENT(in)
:: key input key
INTEGER,
INTENT(out)
:: val output value, equals to 0 if key not found
LOGICAL,
INTENT(out)
:: found .TRUE. if key is found, .FALSE. otherwise

PURE FUNCTIONfb_hash_table_has_data(hash_table)

check if the object has data associated to it

Return Value ::
LOGICAL
true if hash_table%obj is associated, false otherwise
Arguments:
INTENT(in)
:: hash_table the fb_hash_table object in question

PURE SUBROUTINEfb_hash_table_nullify(hash_table)

Nullifies a fb_hash_table object

Arguments:
INTENT(inout)
:: hash_table the fb_hash_table object

SUBROUTINEfb_hash_table_release(hash_table)

releases given object

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

private Parameters/Types:

private Types:

TYPE :: fb_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 :: fb_hash_table_element

hash table entry data type


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