Hash table class to storage any contents by means of generic dictionary buckets.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
type(dictionary), | private, | allocatable | :: | bucket(:) | Hash table buckets. |
||
integer(kind=I8P), | private, | allocatable | :: | ids_(:,:) | Minimum and maximum id values actually stored into each bucket. |
||
integer(kind=I4P), | private | :: | nodes_number_ | = | 0_I4P | Number of nodes actually stored, namely the hash table length. |
|
integer(kind=I4P), | private | :: | me | = | 0 | Index of current CAF image. |
|
integer(kind=I4P), | private | :: | images_number | = | 0 | Number of CAF images. |
|
integer(kind=I4P), | private | :: | buckets_number | = | 0_I4P | Number of buckets used. |
|
logical, | private | :: | is_homogeneous_ | = | .false. | Homogeneity status-guardian. |
|
logical, | private | :: | is_initialized_ | = | .false. | Initialization status. |
|
class(*), | private, | allocatable | :: | typeguard_key | Key type guard (mold) for homogeneous keys check. |
||
class(*), | private, | allocatable | :: | typeguard_content | Content type guard (mold) for homogeneous contents check. |
Finalize the hash table.
Finalize the hash table.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(hash_table), | intent(inout) | :: | self | The hash table. |
Add a node pointer to the hash table.
Add a node pointer to the hash table.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(hash_table), | intent(inout) | :: | self | The hash table. |
||
class(*), | intent(in) | :: | key | The key. |
||
class(*), | intent(in), | pointer | :: | content | The content. |
Add a node to the hash table cloning contents (non pointer add).
Add a node to the hash table cloning content (non pointer add).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(hash_table), | intent(inout) | :: | self | The hash table. |
||
class(*), | intent(in) | :: | key | The key. |
||
class(*), | intent(in) | :: | content | The content. |
Destroy the hash table.
Destroy the hash table.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(hash_table), | intent(inout) | :: | self | The hash table. |
Return a node's content in the hash table by cloning.
Return a node's content by cloning.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(dictionary), | intent(in) | :: | self | The dictionary. |
||
class(*), | intent(in) | :: | key | The key. |
||
class(*), | intent(out), | allocatable | :: | content | Content of the queried node. |
Return a pointer to a node's content in the hash table.
Return a pointer to a node's content in the hash table.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(hash_table), | intent(in) | :: | self | The hash table. |
||
class(*), | intent(in) | :: | key | The key. |
Content pointer of the queried node.
Check if the key is present in the hash table.
Check if the key is present in the hash table.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(hash_table), | intent(in) | :: | self | The hash table. |
||
class(*), | intent(in) | :: | key | The key. |
Check result.
Return the list of ids actually stored.
Return the minimum and maximum unique key id values actually stored.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(hash_table), | intent(in) | :: | self | The hash table. |
||
logical, | intent(in), | optional | :: | global | Check the global values on all CAF images rather only on the local image. |
Minimum and maximum id values actually stored.
Initialize the hash table.
Initialize the hash table.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(hash_table), | intent(inout) | :: | self | The hash table. |
||
integer(kind=I4P), | intent(in), | optional | :: | buckets_number | Number of buckets for initialize the hash table. |
|
logical, | intent(in), | optional | :: | use_prime | If true the buckets number is rendered prime. |
|
logical, | intent(in), | optional | :: | homogeneous | If true the hash is supposed to accept only homogeneous nodes. |
|
class(*), | intent(in), | optional | :: | typeguard_key | Key type guard (mold) for homogeneous keys check. |
|
class(*), | intent(in), | optional | :: | typeguard_content | content type guard (mold) for homogeneous contents check. |
Return homogeneity status.
Return homogeneity status.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(hash_table), | intent(in) | :: | self | The hash table. |
Homogeneity status.
Return initialization status.
Return initialization status.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(hash_table), | intent(in) | :: | self | The hash table. |
Initialization status.
Print the hash table keys.
Print the hash table keys.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(hash_table), | intent(in) | :: | self | The hash table. |
Remove a node from the hash table, given the key.
Remove a node from the hash table, given the key.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(hash_table), | intent(inout) | :: | self | The hash table. |
||
class(*), | intent(in) | :: | key | The key. |
Traverse hash table calling the iterator procedure.
Traverse hash table calling the iterator procedure.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(hash_table), | intent(in) | :: | self | The hash_table. |
||
procedure(key_iterator_interface) | :: | iterator | The (key) iterator procedure to call for each node. |
Allocate dynamic memory members.
Allocate dynamic memory members.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(hash_table), | intent(inout) | :: | self | The hash table. |
||
class(*), | intent(in), | optional | :: | typeguard_key | Key type guard (mold) for homogeneous keys check. |
|
class(*), | intent(in), | optional | :: | typeguard_content | content type guard (mold) for homogeneous contents check. |
Check type consistency.
Check type consistency.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(hash_table), | intent(inout) | :: | self | The hash table. |
||
class(*), | intent(in) | :: | key | The key. |
||
class(*), | intent(in) | :: | content | The content. |
Get the bucket and image indexes corresponding to the given key.
Get the bucket and image indexes corresponding to the given key.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(hash_table), | intent(in) | :: | self | The hash table. |
||
class(*), | intent(in) | :: | key | The key. |
||
integer(kind=I4P), | intent(out) | :: | bucket | Bucket index. |
||
integer(kind=I4P), | intent(out) | :: | image | Image index. |
Hash the key.
Hash the key.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(hash_table), | intent(in) | :: | self | The hash table. |
||
class(*), | intent(in) | :: | key | Key to hash. |
Bucket index corresponding to the key.
Set buckets number.
Set buckets number.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(hash_table), | intent(inout) | :: | self | The hash table. |
||
integer(kind=I4P), | intent(in), | optional | :: | buckets_number | Number of buckets for initialize the hash table. |
|
logical, | intent(in), | optional | :: | use_prime | If true the buckets number is rendered prime. |
Set CAF dimensions by means of intrinsic inquiring functions.
Set CAF dimensions by means of intrinsic inquiring functions.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(hash_table), | intent(inout) | :: | self | The hash table. |
Set homogeneity flag.
Set homogeneity flag.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(hash_table), | intent(inout) | :: | self | The hash table. |
||
logical, | intent(in), | optional | :: | homogeneous | If true the hash is supposed to accept only homogeneous nodes. |
Syncrhonize CAF images.
Synchronize CAF images.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(hash_table), | intent(inout) | :: | self | The hash table. |
type :: hash_table
!< **Hash table** class to storage any contents by means of generic dictionary buckets.
private
#ifdef CAF
type(dictionary), allocatable :: bucket(:)[:] !< Hash table buckets.
integer(I8P), allocatable :: ids_(:,:)[:] !< Minimum and maximum id values actually stored into each bucket.
integer(I4P), allocatable :: nodes_number_[:] !< Number of nodes actually stored, namely the hash table length.
#else
type(dictionary), allocatable :: bucket(:) !< Hash table buckets.
integer(I8P), allocatable :: ids_(:,:) !< Minimum and maximum id values actually stored into each bucket.
integer(I4P) :: nodes_number_=0_I4P !< Number of nodes actually stored, namely the hash table length.
#endif
integer(I4P) :: me=0 !< Index of current CAF image.
integer(I4P) :: images_number=0 !< Number of CAF images.
integer(I4P) :: buckets_number=0_I4P !< Number of buckets used.
logical :: is_homogeneous_=.false. !< Homogeneity status-guardian.
logical :: is_initialized_=.false. !< Initialization status.
class(*), allocatable :: typeguard_key !< Key type guard (mold) for homogeneous keys check.
class(*), allocatable :: typeguard_content !< Content type guard (mold) for homogeneous contents check.
contains
! public methods
procedure, pass(self) :: add_pointer !< Add a node pointer to the hash table.
procedure, pass(self) :: add_clone !< Add a node to the hash table cloning contents (non pointer add).
procedure, pass(self) :: destroy !< Destroy the hash table.
procedure, pass(self) :: get_clone !< Return a node's content in the hash table by cloning.
procedure, pass(self) :: get_pointer !< Return a pointer to a node's content in the hash table.
procedure, pass(self) :: has_key !< Check if the key is present in the hash table.
procedure, pass(self) :: ids !< Return the list of ids actually stored.
procedure, pass(self) :: initialize !< Initialize the hash table.
procedure, pass(self) :: is_homogeneous !< Return homogeneity status.
procedure, pass(self) :: is_initialized !< Return initialization status.
procedure, pass(self) :: print_keys !< Print the hash table keys.
procedure, pass(self) :: remove !< Remove a node from the hash table, given the key.
procedure, pass(self) :: traverse !< Traverse hash table calling the iterator procedure.
! private methods
procedure, pass(self), private :: allocate_members !< Allocate dynamic memory members.
procedure, pass(self), private :: check_type !< Check type consistency.
procedure, pass(self), private :: get_bucket_image_indexes !< Get the bucket and image indexes corresponding to the given key.
procedure, pass(self), private :: hash !< Hash the key.
procedure, pass(self), private :: set_buckets_number !< Set buckets number.
procedure, pass(self), private :: set_caf_dimensions !< Set CAF dimensions by means of intrinsic inquiring functions.
procedure, pass(self), private :: set_homogeneous !< Set homogeneity flag.
procedure, pass(self), private :: synchronize_images !< Syncrhonize CAF images.
! finalizer
final :: finalize !< Finalize the hash table.
endtype hash_table