HASTY dictionary class.
Overload len
builtin for accepting a dictionary.
Return the number of nodes of the dictionary, namely the dictionary length.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(dictionary), | intent(in) | :: | self | The dictionary. |
The dictionary length.
Iterator procedure for traversing all nodes in a dictionary by keys.
Iterator procedure for traversing all nodes in a dictionary by keys.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(*), | intent(in) | :: | key | The node key. |
||
class(*), | intent(in), | pointer | :: | content | The generic content. |
|
logical, | intent(out) | :: | done | Flag to set to true to stop traversing. |
Iterator procedure for traversing all nodes in a dictionary.
Iterator procedure for traversing all nodes in a dictionary.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(dictionary_node), | intent(in), | pointer | :: | node | Actual node pointer in the dictionary. |
|
logical, | intent(out) | :: | done | Flag to set to true to stop traversing. |
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. |
final :: finalize | Finalize the dictionary. |
procedure, public, pass(self) :: add_pointer | Add a node pointer to the dictionary. |
procedure, public, pass(self) :: add_clone | Add a node to the dictionary cloning contents (non pointer add). |
procedure, public, pass(self) :: destroy | Destroy the dictionary. |
procedure, public, pass(self) :: get_clone | Return a node's content by cloning. |
procedure, public, pass(self) :: get_pointer | Return a pointer to a node's content. |
procedure, public, pass(self) :: ids | Return the list of ids actually stored. |
procedure, public, pass(self) :: has_key | Check if the key is present in the dictionary. |
procedure, public, pass(self) :: loop | Sentinel while-loop on nodes returning the key/content pair (for dictionary looping). |
procedure, public, pass(self) :: node | Return a pointer to a node in the dictionary. |
procedure, public, pass(self) :: print_keys | Print the dictionary keys. |
procedure, public, pass(self) :: remove | Remove a node from the dictionary, given the key. |
procedure, public, pass(self) :: traverse | Traverse dictionary from head to tail calling the iterator procedure. |
procedure, private, pass(self) :: add_id | Add a id to ids list. |
procedure, private, pass(self) :: remove_by_pointer | Remove node from dictionary, given pointer to it. |
procedure, private, pass(self) :: remove_id | Remove a id from ids list. |
procedure, private, pass(self) :: traverse_iterator | Traverse dictionary from head to tail calling the iterator procedure. |
Return the number of nodes of the dictionary, namely the dictionary length.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(dictionary), | intent(in) | :: | self | The dictionary. |
The dictionary length.
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.
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.
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.
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.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(dictionary), | intent(in) | :: | self | The dictionary. |
||
class(*), | intent(in) | :: | key | The key. |
Pointer to node queried.
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 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.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(dictionary), | intent(inout) | :: | self | The dictionary. |
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. |
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.
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.
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 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.
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.
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.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(dictionary), | intent(in) | :: | self | The dictionary. |
||
procedure(iterator_interface) | :: | iterator | The iterator procedure to call for each node. |
Finalize the dictionary.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(dictionary), | intent(inout) | :: | self | The dictionary. |