Module ppm_module_inl_hash

This module provides the utility to insert index of a cell and its position on borders array, as the range of indices of cells can be very too large to allocate memory space for whole range. Hence, hash table is the workaround for the redundancy in terms of memory consumption.

Defined Types

name description

ppm_htable

Defined Module Interfaces

name description

no interfaces

Defined Module Subroutines

name description

create_htable

Given number of rows of the table, creates the hash table. Number of

destroy_htable

h_func

h_key

Given the key and jump value, returns corresponding address on

hash_insert

Given the key and the value, stores both in the hash table. Info is

hash_search

Given the key, searchs the key on the hash table and returns the

Type ppm_htable

Defined Type Members

name type dimension description

borders_pos

integer array

(:)

Array for keeping positions of cells on "borders" array.

keys

integer array

(:)

Array for keeping hash table keys.

nrow

integer

number of rows in hash table

borders_pos

integer array, (:)

Array for keeping positions of cells on "borders" array.

keys

integer array, (:)

Array for keeping hash table keys.

nrow

integer,

number of rows in hash table

Subroutine create_htable

Given number of rows of the table, creates the hash table. Number of rows will be greater than nelement, as we use the first value that is power of 2 and greater than nelement.

[Warning]Warning

If you allocate a hashtable with more than 2^31-1 elements the hash function will most probably produce incorrect hash keys and fail.

Arguments

name type dimension intent optional description

table

ppm_htable

(INOUT)

The hashtable to create.

nelement

integer

(IN)

Number of desired elements.

info

integer

(OUT)

table

ppm_htable, , (INOUT)

The hashtable to create.

nelement

integer, , (IN)

Number of desired elements.

info

integer, , (OUT)

Used Modules

ppm_module_data, ppm_module_alloc, ppm_module_error, ppm_module_substop, ppm_module_substart

Subroutine destroy_htable

Arguments

name type dimension intent optional description

table

ppm_htable

(INOUT)

The hashtable to create. The pointer must not be NULL

info

integer

(OUT)

table

ppm_htable, , (INOUT)

The hashtable to create. The pointer must not be NULL

info

integer, , (OUT)

Used Modules

ppm_module_data, ppm_module_alloc, ppm_module_error, ppm_module_substop, ppm_module_substart

Subroutine h_func

Arguments

name type dimension intent optional description

table

ppm_htable

(IN)

The hashtable to create. The pointer must not be NULL

key

integer

(IN)

Input key

seed

integer

(IN)

Seed to be used for mixing

table

ppm_htable, , (IN)

The hashtable to create. The pointer must not be NULL

key

integer, , (IN)

Input key

seed

integer, , (IN)

Seed to be used for mixing

Used Modules

has no uses

Subroutine h_key

Given the key and jump value, returns corresponding address on "borders" array.

Arguments

name type dimension intent optional description

table

ppm_htable

(IN)

The hashtable to create. The pointer must not be NULL

key

integer

(IN)

Input key, which corresponds to address requested

jump

integer

(IN)

Jump value for double hashing

table

ppm_htable, , (IN)

The hashtable to create. The pointer must not be NULL

key

integer, , (IN)

Input key, which corresponds to address requested

jump

integer, , (IN)

Jump value for double hashing

Used Modules

has no uses

Subroutine hash_insert

Given the key and the value, stores both in the hash table. Info is set to -1 if size of the hash table is not sufficient.

[Note]Note

This routine needs to be very fast, therefor we skip the usual chit-chat and get right to it. (→ no substart,substop unless compiled with __DEBUG flag)

Arguments

name type dimension intent optional description

table

ppm_htable

(INOUT)

The hashtable to create. The pointer must not be NULL

key

integer

(IN)

Key to be stored

value

integer

(IN)

Value that corresponds to given key

info

integer

(OUT)

Info for whether insertion was successful or not. 0 if SUCCESSFUL

table

ppm_htable, , (INOUT)

The hashtable to create. The pointer must not be NULL

key

integer, , (IN)

Key to be stored

value

integer, , (IN)

Value that corresponds to given key

info

integer, , (OUT)

Info for whether insertion was successful or not. 0 if SUCCESSFUL and -1 otherwise.

Used Modules

has no uses

Subroutine hash_search

Given the key, searchs the key on the hash table and returns the corresponding value.

[Note]Note

This routine needs to be very fast, therefor we skip the usual chit-chat and get right to it. (→ no substart,substop unless compiled with __DEBUG flag)

Arguments

name type dimension intent optional description

table

ppm_htable

(IN)

The hashtable to create. The pointer must not be NULL

key

integer

(IN)

Input key, which the corresponding value is asked for

table

ppm_htable, , (IN)

The hashtable to create. The pointer must not be NULL

key

integer, , (IN)

Input key, which the corresponding value is asked for

Used Modules

has no uses

Defined Module Variables

name type dimension description

htable_null

integer

NULL value for hash table

htable_null

integer,

NULL value for hash table

Used Modules

ppm_module_data, ppm_module_alloc, ppm_module_error