dictionary Derived Type

type, public :: dictionary

type~~dictionary~~InheritsGraph type~dictionary dictionary type~dictionary_node dictionary_node type~dictionary_node->type~dictionary head, tail type~dictionary_node->type~dictionary_node next, previous type~key_base key_base type~key_base->type~dictionary_node key
Help


Dictionary class to storage any contents by means of generic key/content pairs nodes.

Inherited By

type~~dictionary~~InheritedByGraph type~dictionary dictionary type~hash_table hash_table type~dictionary->type~hash_table bucket
Help

Source Code


Components

TypeVisibility AttributesNameInitial
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.


Finalization Procedures

final :: finalize

Finalize the dictionary.

  • private elemental subroutine finalize(self)

    Finalize the dictionary.

    Arguments

    Type IntentOptional AttributesName
    type(dictionary), intent(inout) :: self

    The dictionary.


Type-Bound Procedures

procedure, public, pass(self) :: add_pointer

Add a node pointer to the dictionary.

  • private subroutine add_pointer(self, key, content, buckets_number)

    Add a node pointer to the dictionary.

    Arguments

    Type IntentOptional AttributesName
    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.

procedure, public, pass(self) :: add_clone

Add a node to the dictionary cloning contents (non pointer add).

  • private subroutine add_clone(self, key, content, buckets_number)

    Add a node to the dictionary cloning content (non pointer add).

    Arguments

    Type IntentOptional AttributesName
    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.

procedure, public, pass(self) :: destroy

Destroy the dictionary.

  • private elemental subroutine destroy(self)

    Destroy the dictionary.

    Arguments

    Type IntentOptional AttributesName
    class(dictionary), intent(inout) :: self

    The dictionary.

procedure, public, pass(self) :: get_clone

Return a node's content by cloning.

  • public subroutine get_clone(self, key, content)

    Return a node's content by cloning.

    Arguments

    Type IntentOptional AttributesName
    class(dictionary), intent(in) :: self

    The dictionary.

    class(*), intent(in) :: key

    The key.

    class(*), intent(out), allocatable:: content

    Content of the queried node.

procedure, public, pass(self) :: get_pointer

Return a pointer to a node's content.

  • private function get_pointer(self, key) result(content)

    Return a pointer to a node's content.

    Arguments

    Type IntentOptional AttributesName
    class(dictionary), intent(in) :: self

    The dictionary.

    class(*), intent(in) :: key

    The key.

    Return Value class(*), pointer

    Content pointer of the queried node.

procedure, public, pass(self) :: ids

Return the list of ids actually stored.

  • private pure function ids(self)

    Return the minimum and maximum unique key id values actually stored.

    Arguments

    Type IntentOptional AttributesName
    class(dictionary), intent(in) :: self

    The dictionary.

    Return Value integer(kind=I8P) (1:2)

    Minimum and maximum id values actually stored.

procedure, public, pass(self) :: has_key

Check if the key is present in the dictionary.

  • private function has_key(self, key)

    Check if the key is present in the dictionary.

    Arguments

    Type IntentOptional AttributesName
    class(dictionary), intent(in) :: self

    The dictionary.

    class(*), intent(in) :: key

    The key.

    Return Value logical

    Check result.

procedure, public, pass(self) :: loop

Sentinel while-loop on nodes returning the key/content pair (for dictionary looping).

  • private function loop(self, key, content) result(again)

    Sentinel while-loop on nodes returning the key/content pair (for dictionary looping).

    Arguments

    Type IntentOptional AttributesName
    class(dictionary), intent(in) :: self

    The dictionary.

    class(*), intent(out), optional allocatable:: key

    The key.

    class(*), intent(out), optional pointer:: content

    The content.

    Return Value logical

    Sentinel flag to contine the loop.

procedure, public, pass(self) :: node

Return a pointer to a node in the dictionary.

  • private function node(self, key) result(p)

    Return a pointer to a node in the dictionary.

    Arguments

    Type IntentOptional AttributesName
    class(dictionary), intent(in) :: self

    The dictionary.

    class(*), intent(in) :: key

    The key.

    Return Value type(dictionary_node), pointer

    Pointer to node queried.

procedure, public, pass(self) :: print_keys

Print the dictionary keys.

  • private subroutine print_keys(self)

    Print the dictionary keys.

    Arguments

    Type IntentOptional AttributesName
    class(dictionary), intent(in) :: self

    The dictionary.

procedure, public, pass(self) :: remove

Remove a node from the dictionary, given the key.

  • private subroutine remove(self, key)

    Remove a node from the dictionary, given the key.

    Arguments

    Type IntentOptional AttributesName
    class(dictionary), intent(inout) :: self

    The dictionary.

    class(*), intent(in) :: key

    The key.

procedure, public, pass(self) :: traverse

Traverse dictionary from head to tail calling the iterator procedure.

  • private subroutine traverse(self, iterator)

    Traverse dictionary from head to tail calling the iterator procedure.

    Arguments

    Type IntentOptional AttributesName
    class(dictionary), intent(in) :: self

    The dictionary.

    procedure(key_iterator_interface) :: iterator

    The (key) iterator procedure to call for each node.

procedure, private, pass(self) :: add_id

Add a id to ids list.

  • private pure subroutine add_id(self, id)

    Add a id to minimum and maximum unique key id values.

    Arguments

    Type IntentOptional AttributesName
    class(dictionary), intent(inout) :: self

    The dictionary.

    integer(kind=I8P), intent(in) :: id

    Unique id to add.

procedure, private, pass(self) :: remove_by_pointer

Remove node from dictionary, given pointer to it.

  • private subroutine remove_by_pointer(self, p)

    Remove node from dictionary, given pointer to it.

    Arguments

    Type IntentOptional AttributesName
    class(dictionary), intent(inout) :: self

    The dictionary.

    type(dictionary_node), intent(inout), pointer:: p

    Pointer to the node to remove.

procedure, private, pass(self) :: remove_id

Remove a id from ids list.

  • private subroutine remove_id(self, id)

    Remove a id from ids list.

    Arguments

    Type IntentOptional AttributesName
    class(dictionary), intent(inout) :: self

    The dictionary.

    integer(kind=I8P), intent(in) :: id

    Unique id to add.

procedure, private, pass(self) :: traverse_iterator

Traverse dictionary from head to tail calling the iterator procedure.

  • private subroutine traverse_iterator(self, iterator)

    Traverse dictionary from head to tail calling the iterator procedure.

    Arguments

    Type IntentOptional AttributesName
    class(dictionary), intent(in) :: self

    The dictionary.

    procedure(iterator_interface) :: iterator

    The iterator procedure to call for each node.

Source Code

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