key_base Derived Type

type, public :: key_base

Key class to identify a node.

It can be extended by user.

Inherited By

type~~key_base~~InheritedByGraph type~key_base key_base type~dictionary_node dictionary_node type~key_base->type~dictionary_node key type~key_morton key_morton type~key_base->type~key_morton type~dictionary_node->type~dictionary_node next, previous type~dictionary dictionary type~dictionary_node->type~dictionary head, tail type~hash_table hash_table type~dictionary->type~hash_table bucket
Help

Source Code


Components

TypeVisibility AttributesNameInitial
integer(kind=I8P), private, allocatable:: id_

Unique key id.

character(len=:), private, allocatable:: char_key_

Store character key.


Constructor

public interface key_base

  • private elemental function creator(key, buckets_number) result(key_)

    Return an instance of key_base

    Arguments

    Type IntentOptional AttributesName
    class(*), intent(in) :: key

    The key value.

    integer(kind=I4P), intent(in), optional :: buckets_number

    Buckets number.

    Return Value type(key_base)

    Instance of key_base.


Type-Bound Procedures

procedure, public, pass(self) :: destroy

Destroy the key.

  • private elemental subroutine destroy(self)

    Destroy the key.

    Arguments

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

    The key.

procedure, public, pass(self) :: hash

Hash the key.

  • private elemental function hash(self, buckets_number) result(bucket)

    Hash the key.

    Arguments

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

    The key.

    integer(kind=I4P), intent(in) :: buckets_number

    Buckets number.

    Return Value integer(kind=I4P)

    Bucket index corresponding to the key.

procedure, public, pass(self) :: id

Return the id.

  • private elemental function id(self)

    Return the id.

    Arguments

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

    The key.

    Return Value integer(kind=I8P)

    Unique key id.

procedure, public, nopass :: is_key_allowed

Typeguard for used key.

  • public elemental function is_key_allowed(key)

    Typeguard for used key.

    Arguments

    Type IntentOptional AttributesName
    class(*), intent(in) :: key

    The key ID.

    Return Value logical

    Check result.

procedure, public, pass(self) :: set

Set the key.

  • private elemental subroutine set(self, key, buckets_number)

    Set the key.

    Arguments

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

    The key.

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

    The key value.

    integer(kind=I4P), intent(in), optional :: buckets_number

    Buckets number.

procedure, public, pass(self) :: stringify

Return a string representation of the key.

  • private pure function stringify(self) result(str_key)

    Return a string representation of the key.

    Arguments

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

    The key.

    Return Value character(len=:), allocatable

    The key stringified.

generic, public :: operator(==) => is_equal

Overloading == operator.

  • private elemental function is_equal(lhs, rhs)

    Implement == operator.

    Arguments

    Type IntentOptional AttributesName
    class(key_morton), intent(in) :: lhs

    Left hand side.

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

    Rigth hand side.

    Return Value logical

procedure, private, pass(lhs) :: is_equal

Implement == operator.

  • private elemental function is_equal(lhs, rhs)

    Implement == operator.

    Arguments

    Type IntentOptional AttributesName
    class(key_base), intent(in) :: lhs

    Left hand side.

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

    Rigth hand side.

    Return Value logical

procedure, private, nopass :: hash_string

Hash a string.

  • private elemental function hash_string(string, buckets_number) result(bucket)

    Hash a string.

    Arguments

    Type IntentOptional AttributesName
    character(len=*), intent(in) :: string

    The string.

    integer(kind=I4P), intent(in) :: buckets_number

    Buckets number.

    Return Value integer(kind=I8P)

    Bucket index corresponding to the string.

Source Code

type :: key_base
  !< **Key** class to identify a node.
  !<
  !< It can be extended by user.
  private
  integer(I8P),     allocatable :: id_       !< Unique key id.
  character(len=:), allocatable :: char_key_ !< Store character key.
  contains
    ! public methods
    procedure, pass(self) :: destroy        !< Destroy the key.
    procedure, pass(self) :: hash           !< Hash the key.
    procedure, pass(self) :: id             !< Return the id.
    procedure, nopass     :: is_key_allowed !< Typeguard for used key.
    procedure, pass(self) :: set            !< Set the key.
    procedure, pass(self) :: stringify      !< Return a string representation of the key.
    ! public generics
    generic, public :: operator(==) => is_equal !< Overloading `==` operator.
    ! private methods
    procedure, pass(lhs),  private :: is_equal    !< Implement `==` operator.
    procedure, nopass,     private :: hash_string !< Hash a string.
endtype key_base