Dictionary type that uses strings for the keys and values.
More...
|
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...
|
|
Dictionary type that uses strings for the keys and values.
Design:
- djb2 hash function (D. J. Bernstein, see http://www.cse.yorku.ca/~oz/hash.html)
- The strings are all "character(len=:), allocatable" variables
- There is no linked list nor pointers, only allocatable arrays for the dynamic data structure
- set rewrites existing entries without complaining
Definition at line 12 of file dictionary_m.f90.
integer function dictionary_m::djb2 |
( |
class(dictionary_t), intent(in) |
this, |
|
|
character(len=*), intent(in) |
s |
|
) |
| |
|
private |
djb2 hash function
- Parameters
-
- 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
-
- 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
-
- 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
-
this | the dictionary_t object |
dict_size | the 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
-
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
-
Definition at line 151 of file dictionary_m.f90.
integer, parameter dictionary_m::bucket_empty = -2 |
|
private |
integer, parameter dictionary_m::bucket_entry_not_found = -4 |
|
private |
The documentation for this module was generated from the following file: