Fortran hash table  0.1
 All Classes Namespaces Files Functions Variables
Data Types | Private Member Functions | Private Attributes | List of all members
dictionary_m Module Reference

Dictionary type that uses strings for the keys and values. More...

Data Types

type  bucket_t
 A bucket contains several entries. More...
 
type  dictionary_t
 The dictionary contains dict_size buckets (defined at run time) More...
 
type  entry_t
 Single entry in the dictionary. More...
 

Private Member Functions

integer function djb2 (this, s)
 djb2 hash function More...
 
subroutine set (this, k, v)
 Add or replace an entry in the dictionary. More...
 
subroutine init (this, dict_size)
 Initialize a dictionary object. More...
 
subroutine show (this)
 Display the content of a dictionary. More...
 
integer function find (this, k)
 Find the "in-bucket" index for a given key. More...
 
character(len=:) function,
allocatable 
get (this, k)
 Fetch an entry in the dictionary. More...
 

Private Attributes

integer, parameter bucket_empty = -2
 
integer, parameter bucket_entry_not_found = -4
 

Detailed Description

Dictionary type that uses strings for the keys and values.

Design:

Definition at line 12 of file dictionary_m.f90.

Member Function/Subroutine Documentation

integer function dictionary_m::djb2 ( class(dictionary_t), intent(in)  this,
character(len=*), intent(in)  s 
)
private

djb2 hash function

Parameters
thisthe dictionary_t object
sa string
Returns
the hash value between 0 and dict_size-1

Definition at line 57 of file dictionary_m.f90.

integer function dictionary_m::find ( class(bucket_t), intent(in)  this,
character(len=*), intent(in)  k 
)
private

Find the "in-bucket" index for a given key.

Negative return values correspond to module-defined return codes.

Parameters
thisthe bucket_t object
kthe key
Returns
the index (1-based) of the key in the bucket or a return code

Definition at line 179 of file dictionary_m.f90.

character(len=:) function, allocatable dictionary_m::get ( class(dictionary_t), intent(in)  this,
character(len=*), intent(in)  k 
)
private

Fetch an entry in the dictionary.

Parameters
thisthe dictionary_t object
kthe key
Returns
the value if found, an empty string else

Definition at line 207 of file dictionary_m.f90.

subroutine dictionary_m::init ( class(dictionary_t), intent(out)  this,
integer, intent(in)  dict_size 
)
private

Initialize a dictionary object.

Parameters
thisthe dictionary_t object
dict_sizethe size of the hash table

Definition at line 139 of file dictionary_m.f90.

subroutine dictionary_m::set ( class(dictionary_t), intent(inout)  this,
character(len=*), intent(in)  k,
character(len=*), intent(in)  v 
)
private

Add or replace an entry in the dictionary.

Parameters
thisthe dictionary_t object
kthe key
vthe value

Definition at line 81 of file dictionary_m.f90.

subroutine dictionary_m::show ( class(dictionary_t), intent(in)  this)
private

Display the content of a dictionary.

Parameters
thisthe dictionary_t object

Definition at line 151 of file dictionary_m.f90.

Member Data Documentation

integer, parameter dictionary_m::bucket_empty = -2
private

Definition at line 46 of file dictionary_m.f90.

integer, parameter dictionary_m::bucket_entry_not_found = -4
private

Definition at line 47 of file dictionary_m.f90.


The documentation for this module was generated from the following file: