Dictionary class to storage any contents by means of generic key/content pairs nodes.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
type(dictionary_node), | private, | pointer | :: | head | => | null() | The first node in the dictionary. |
type(dictionary_node), | private, | pointer | :: | tail | => | null() | The last node in the dictionary. |
integer(kind=I4P), | private | :: | nodes_number | = | 0 | Number of nodes in the dictionary. |
|
integer(kind=I8P), | private | :: | ids_(1:2) | = | [0, 0] | Minimum and maximum unique key id values actually stored. |
Finalize the dictionary.
Finalize the dictionary.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(dictionary), | intent(inout) | :: | self | The dictionary. |
Add a node pointer to the dictionary.
Add a node pointer to the dictionary.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(dictionary), | intent(inout) | :: | self | The dictionary. |
||
class(*), | intent(in) | :: | key | The key. |
||
class(*), | intent(in), | pointer | :: | content | The content. |
|
integer(kind=I4P), | intent(in), | optional | :: | buckets_number | Buckets number. |
Add a node to the dictionary cloning contents (non pointer add).
Add a node to the dictionary cloning content (non pointer add).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(dictionary), | intent(inout) | :: | self | The dictionary. |
||
class(*), | intent(in) | :: | key | The key. |
||
class(*), | intent(in) | :: | content | The content. |
||
integer(kind=I4P), | intent(in), | optional | :: | buckets_number | Buckets number. |
Destroy the dictionary.
Destroy the dictionary.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(dictionary), | intent(inout) | :: | self | The dictionary. |
Return a node's content 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.
Return a pointer to a node's content.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(dictionary), | intent(in) | :: | self | The dictionary. |
||
class(*), | intent(in) | :: | key | The key. |
Content pointer of the queried node.
Return the list of ids actually stored.
Return the minimum and maximum unique key id values actually stored.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(dictionary), | intent(in) | :: | self | The dictionary. |
Minimum and maximum id values actually stored.
Check if the key is present in the dictionary.
Check if the key is present in the dictionary.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(dictionary), | intent(in) | :: | self | The dictionary. |
||
class(*), | intent(in) | :: | key | The key. |
Check result.
Sentinel while-loop on nodes returning the key/content pair (for dictionary looping).
Sentinel while-loop on nodes returning the key/content pair (for dictionary looping).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(dictionary), | intent(in) | :: | self | The dictionary. |
||
class(*), | intent(out), | optional | allocatable | :: | key | The key. |
class(*), | intent(out), | optional | pointer | :: | content | The content. |
Sentinel flag to contine the loop.
Return a pointer to a node in the dictionary.
Return a pointer to a node in the dictionary.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(dictionary), | intent(in) | :: | self | The dictionary. |
||
class(*), | intent(in) | :: | key | The key. |
Pointer to node queried.
Print the dictionary keys.
Print the dictionary keys.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(dictionary), | intent(in) | :: | self | The dictionary. |
Remove a node from the dictionary, given the key.
Remove a node from the dictionary, given the key.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(dictionary), | intent(inout) | :: | self | The dictionary. |
||
class(*), | intent(in) | :: | key | The key. |
Traverse dictionary from head to tail calling the iterator procedure.
Traverse dictionary from head to tail calling the iterator procedure.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(dictionary), | intent(in) | :: | self | The dictionary. |
||
procedure(key_iterator_interface) | :: | iterator | The (key) iterator procedure to call for each node. |
Add a id to ids list.
Add a id to minimum and maximum unique key id values.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(dictionary), | intent(inout) | :: | self | The dictionary. |
||
integer(kind=I8P), | intent(in) | :: | id | Unique id to add. |
Remove node from dictionary, given pointer to it.
Remove node from dictionary, given pointer to it.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(dictionary), | intent(inout) | :: | self | The dictionary. |
||
type(dictionary_node), | intent(inout), | pointer | :: | p | Pointer to the node to remove. |
Remove a id from ids list.
Remove a id from ids list.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(dictionary), | intent(inout) | :: | self | The dictionary. |
||
integer(kind=I8P), | intent(in) | :: | id | Unique id to add. |
Traverse dictionary from head to tail calling the iterator procedure.
Traverse dictionary from head to tail calling the iterator procedure.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(dictionary), | intent(in) | :: | self | The dictionary. |
||
procedure(iterator_interface) | :: | iterator | The iterator procedure to call for each node. |
type :: dictionary
!< **Dictionary** class to storage any contents by means of generic key/content pairs nodes.
private
type(dictionary_node), pointer :: head=>null() !< The first node in the dictionary.
type(dictionary_node), pointer :: tail=>null() !< The last node in the dictionary.
integer(I4P) :: nodes_number=0 !< Number of nodes in the dictionary.
integer(I8P) :: ids_(1:2)=[0,0] !< Minimum and maximum unique key id values actually stored.
contains
! public methods
procedure, pass(self) :: add_pointer !< Add a node pointer to the dictionary.
procedure, pass(self) :: add_clone !< Add a node to the dictionary cloning contents (non pointer add).
procedure, pass(self) :: destroy !< Destroy the dictionary.
procedure, pass(self) :: get_clone !< Return a node's content by cloning.
procedure, pass(self) :: get_pointer !< Return a pointer to a node's content.
procedure, pass(self) :: ids !< Return the list of ids actually stored.
procedure, pass(self) :: has_key !< Check if the key is present in the dictionary.
procedure, pass(self) :: loop !< Sentinel while-loop on nodes returning the key/content pair (for dictionary looping).
procedure, pass(self) :: node !< Return a pointer to a node in the dictionary.
procedure, pass(self) :: print_keys !< Print the dictionary keys.
procedure, pass(self) :: remove !< Remove a node from the dictionary, given the key.
procedure, pass(self) :: traverse !< Traverse dictionary from head to tail calling the iterator procedure.
! private methods
procedure, pass(self), private :: add_id !< Add a id to ids list.
procedure, pass(self), private :: remove_by_pointer !< Remove node from dictionary, given pointer to it.
procedure, pass(self), private :: remove_id !< Remove a id from ids list.
procedure, pass(self), private :: traverse_iterator !< Traverse dictionary from head to tail calling the iterator procedure.
! finalizer
final :: finalize !< Finalize the dictionary.
endtype dictionary