Hash tables

January 22, 2021 ยท View on GitHub

Modern Fortran hash tables based on the function hashword in lookup3.c

Derived types

Five derived types are available:

Derived typeData to be stored
table_char_tCharacters of a defined length. Trailing blanks are ignored.
table_int32_tInteger scalars of 32 bits
table_real32_tReal scalars of 32 bits
table_arrint32_tInteger arrays of 32 bits
table_arrreal32_tReal arrays of 32 bits

Public derived type methods

Each derived type contains these 7 public methods.

MethodClassDescription
add(element[, index, lnew])SubroutineAdd the element element in the DT if not stored yet. The integer index (intent(out), optional) contains the index of the elements (between 1 and getfilled(). The logical lnew (intent(out), optional) is .true. if the element is not stored yet. Otherwise it is .false..
destroy()FunctionReset all scalars and arrays
get(index)FunctionReturns the element stored corresponding to the index index.
getfilled()FunctionReturns the number of elements stored in the DT
getindex(element)FunctionReturns the index (between 1 and getfilled()) of the element element
getsize()FunctionReturns the size of the arrays that contains the stored elements
writetable(filename)SubroutineWrites to a file called filename all elements and corresponding index stored in the DT.