dbcsr_dict Module

A dictionary (also known as hashtable or hashmap). Internally the dictionary uses an array to holds its data. If this array reaches a load-factor of 75%, a new array with twice the size will be allocated and the items are then copied over. This ensures that the dictionary will perform operations in O(1).



Contents


Variables

TypeVisibilityAttributesNameInitial
character(len=*), private, parameter:: moduleN ='dbcsr_dict'

Interfaces

public interface dict_init

  • private subroutine dict_str_i4_init(dict, initial_capacity)

    Allocates the internal data-structures of the given dictionary.

    Arguments

    TypeIntentOptionalAttributesName
    type(dict_str_i4_type), intent(inout) :: dict
    integer, intent(in), optional :: initial_capacity

    The initial size of the internal array (default=11).

  • private subroutine dict_i4tuple_callstat_init(dict, initial_capacity)

    Allocates the internal data-structures of the given dictionary.

    Arguments

    TypeIntentOptionalAttributesName
    type(dict_i4tuple_callstat_type), intent(inout) :: dict
    integer, intent(in), optional :: initial_capacity

    The initial size of the internal array (default=11).

public interface dict_haskey

  • private function dict_str_i4_haskey(dict, key) result(res)

    Checks whether a given key is currently stored in the dictionary.

    Arguments

    TypeIntentOptionalAttributesName
    type(dict_str_i4_type), intent(inout) :: dict
    character(len=default_string_length) :: key

    Return Value logical

  • private function dict_i4tuple_callstat_haskey(dict, key) result(res)

    Checks whether a given key is currently stored in the dictionary.

    Arguments

    TypeIntentOptionalAttributesName
    type(dict_i4tuple_callstat_type), intent(inout) :: dict
    integer(kind=int_4), dimension(2):: key

    Return Value logical

public interface dict_set

  • private subroutine dict_str_i4_set(dict, key, value)

    Stores, and possibly overwrites, a given value under a given key.

    Arguments

    TypeIntentOptionalAttributesName
    type(dict_str_i4_type), intent(inout) :: dict
    character(len=default_string_length), intent(in) :: key
    integer(kind=int_4), intent(in) :: value
  • private subroutine dict_i4tuple_callstat_set(dict, key, value)

    Stores, and possibly overwrites, a given value under a given key.

    Arguments

    TypeIntentOptionalAttributesName
    type(dict_i4tuple_callstat_type), intent(inout) :: dict
    integer(kind=int_4), intent(in), dimension(2):: key
    type(call_stat_type), intent(in), POINTER:: value

public interface dict_get

  • private function dict_str_i4_get(dict, key, default_value) result(value)

    Gets a value for a given key from the dictionary. If the key is not found the default_value will be returned. If the key is not found and default_value was not provided the program stops.

    Arguments

    TypeIntentOptionalAttributesName
    type(dict_str_i4_type), intent(inout) :: dict
    character(len=default_string_length) :: key
    integer(kind=int_4), intent(in), optional :: default_value

    Return Value integer(kind=int_4)

  • private function dict_i4tuple_callstat_get(dict, key, default_value) result(value)

    Gets a value for a given key from the dictionary. If the key is not found the default_value will be returned. If the key is not found and default_value was not provided the program stops.

    Arguments

    TypeIntentOptionalAttributesName
    type(dict_i4tuple_callstat_type), intent(inout) :: dict
    integer(kind=int_4), dimension(2):: key
    type(call_stat_type), intent(in), optional POINTER:: default_value

    Return Value type(call_stat_type),POINTER

public interface dict_items

  • private function dict_str_i4_items(dict) result(items)

    Returns a pointer to an array of all key/value-items stored in the dictionary. Caution: The caller is responsible for deallocating targeted array after usage.

    Arguments

    TypeIntentOptionalAttributesName
    type(dict_str_i4_type), intent(inout) :: dict

    Return Value type(dict_str_i4_item_type),dimension(:), POINTER

  • private function dict_i4tuple_callstat_items(dict) result(items)

    Returns a pointer to an array of all key/value-items stored in the dictionary. Caution: The caller is responsible for deallocating targeted array after usage.

    Arguments

    TypeIntentOptionalAttributesName
    type(dict_i4tuple_callstat_type), intent(inout) :: dict

    Return Value type(dict_i4tuple_callstat_item_type),dimension(:), POINTER

public interface dict_size

  • private function dict_str_i4_size(dict) result(size)

    Returns the number of key/value-items currently stored in the dictionary.

    Arguments

    TypeIntentOptionalAttributesName
    type(dict_str_i4_type), intent(inout) :: dict

    Return Value integer

  • private function dict_i4tuple_callstat_size(dict) result(size)

    Returns the number of key/value-items currently stored in the dictionary.

    Arguments

    TypeIntentOptionalAttributesName
    type(dict_i4tuple_callstat_type), intent(inout) :: dict

    Return Value integer

public interface dict_destroy

  • private subroutine dict_str_i4_destroy(dict)

    Deallocated the internal data-structures if the given dictionary. Caution: If the stored keys or values are pointers, their targets will not get deallocated by this routine.

    Arguments

    TypeIntentOptionalAttributesName
    type(dict_str_i4_type), intent(inout) :: dict
  • private subroutine dict_i4tuple_callstat_destroy(dict)

    Deallocated the internal data-structures if the given dictionary. Caution: If the stored keys or values are pointers, their targets will not get deallocated by this routine.

    Arguments

    TypeIntentOptionalAttributesName
    type(dict_i4tuple_callstat_type), intent(inout) :: dict

Derived Types

type, private :: private_item_type_str_i4

Components

TypeVisibilityAttributesNameInitial
character(len=default_string_length), private :: key
integer(kind=int_4), private :: value
integer(kind=int_8), private :: hash
type(private_item_type_str_i4), private, POINTER:: next=> Null()

type, private :: private_item_p_type_str_i4

Components

TypeVisibilityAttributesNameInitial
type(private_item_type_str_i4), private, POINTER:: p=> Null()

type, public :: dict_str_i4_type

Components

TypeVisibilityAttributesNameInitial
type(private_item_p_type_str_i4), private, DIMENSION(:), POINTER:: buckets=> Null()
integer, private :: size =-1

type, public :: dict_str_i4_item_type

Components

TypeVisibilityAttributesNameInitial
character(len=default_string_length), public :: key
integer(kind=int_4), public :: value

Components

TypeVisibilityAttributesNameInitial
integer(kind=int_4), private, dimension(2):: key
type(call_stat_type), private, POINTER:: value
integer(kind=int_8), private :: hash
type(private_item_type_i4tuple_callstat), private, POINTER:: next=> Null()

Components

TypeVisibilityAttributesNameInitial
type(private_item_type_i4tuple_callstat), private, POINTER:: p=> Null()

Components

TypeVisibilityAttributesNameInitial
type(private_item_p_type_i4tuple_callstat), private, DIMENSION(:), POINTER:: buckets=> Null()
integer, private :: size =-1

Components

TypeVisibilityAttributesNameInitial
integer(kind=int_4), public, dimension(2):: key
type(call_stat_type), public, POINTER:: value

Functions

private function hash_str(key) result(hash)

This is joaat_hash from string_table.F, generates the hash of a given string

Read more…

Arguments

TypeIntentOptionalAttributesName
character(len=*), intent(in) :: key

key a string of any length

Return Value integer(kind=int_8)

private function hash_i4tuple(key) result(hash)

Arguments

TypeIntentOptionalAttributesName
integer(kind=int_4), intent(in), dimension(2):: key

Return Value integer(kind=int_4)

private function dict_str_i4_get(dict, key, default_value) result(value)

Gets a value for a given key from the dictionary. If the key is not found the default_value will be returned. If the key is not found and default_value was not provided the program stops.

Arguments

TypeIntentOptionalAttributesName
type(dict_str_i4_type), intent(inout) :: dict
character(len=default_string_length) :: key
integer(kind=int_4), intent(in), optional :: default_value

Return Value integer(kind=int_4)

private function dict_str_i4_size(dict) result(size)

Returns the number of key/value-items currently stored in the dictionary.

Arguments

TypeIntentOptionalAttributesName
type(dict_str_i4_type), intent(inout) :: dict

Return Value integer

private function dict_str_i4_haskey(dict, key) result(res)

Checks whether a given key is currently stored in the dictionary.

Arguments

TypeIntentOptionalAttributesName
type(dict_str_i4_type), intent(inout) :: dict
character(len=default_string_length) :: key

Return Value logical

private function dict_str_i4_items(dict) result(items)

Returns a pointer to an array of all key/value-items stored in the dictionary. Caution: The caller is responsible for deallocating targeted array after usage.

Arguments

TypeIntentOptionalAttributesName
type(dict_str_i4_type), intent(inout) :: dict

Return Value type(dict_str_i4_item_type),dimension(:), POINTER

private function dict_i4tuple_callstat_get(dict, key, default_value) result(value)

Gets a value for a given key from the dictionary. If the key is not found the default_value will be returned. If the key is not found and default_value was not provided the program stops.

Arguments

TypeIntentOptionalAttributesName
type(dict_i4tuple_callstat_type), intent(inout) :: dict
integer(kind=int_4), dimension(2):: key
type(call_stat_type), intent(in), optional POINTER:: default_value

Return Value type(call_stat_type),POINTER

private function dict_i4tuple_callstat_size(dict) result(size)

Returns the number of key/value-items currently stored in the dictionary.

Arguments

TypeIntentOptionalAttributesName
type(dict_i4tuple_callstat_type), intent(inout) :: dict

Return Value integer

private function dict_i4tuple_callstat_haskey(dict, key) result(res)

Checks whether a given key is currently stored in the dictionary.

Arguments

TypeIntentOptionalAttributesName
type(dict_i4tuple_callstat_type), intent(inout) :: dict
integer(kind=int_4), dimension(2):: key

Return Value logical

private function dict_i4tuple_callstat_items(dict) result(items)

Returns a pointer to an array of all key/value-items stored in the dictionary. Caution: The caller is responsible for deallocating targeted array after usage.

Arguments

TypeIntentOptionalAttributesName
type(dict_i4tuple_callstat_type), intent(inout) :: dict

Return Value type(dict_i4tuple_callstat_item_type),dimension(:), POINTER


Subroutines

private subroutine dict_str_i4_init(dict, initial_capacity)

Allocates the internal data-structures of the given dictionary.

Arguments

TypeIntentOptionalAttributesName
type(dict_str_i4_type), intent(inout) :: dict
integer, intent(in), optional :: initial_capacity

The initial size of the internal array (default=11).

private subroutine dict_str_i4_destroy(dict)

Deallocated the internal data-structures if the given dictionary. Caution: If the stored keys or values are pointers, their targets will not get deallocated by this routine.

Arguments

TypeIntentOptionalAttributesName
type(dict_str_i4_type), intent(inout) :: dict

private subroutine dict_str_i4_set(dict, key, value)

Stores, and possibly overwrites, a given value under a given key.

Arguments

TypeIntentOptionalAttributesName
type(dict_str_i4_type), intent(inout) :: dict
character(len=default_string_length), intent(in) :: key
integer(kind=int_4), intent(in) :: value

private recursive subroutine set_hashed_str_i4(dict, key, value, hash)

Common code used internally by dict_set() and change_capacity().

Arguments

TypeIntentOptionalAttributesName
type(dict_str_i4_type), intent(inout) :: dict
character(len=default_string_length), intent(in) :: key
integer(kind=int_4), intent(in) :: value
integer(kind=int_8), intent(in) :: hash

private recursive subroutine change_capacity_str_i4(dict, new_capacity)

Internal routine for changing the dictionary's capacity.

Arguments

TypeIntentOptionalAttributesName
type(dict_str_i4_type), intent(inout) :: dict
integer, intent(in) :: new_capacity

private subroutine dict_i4tuple_callstat_init(dict, initial_capacity)

Allocates the internal data-structures of the given dictionary.

Arguments

TypeIntentOptionalAttributesName
type(dict_i4tuple_callstat_type), intent(inout) :: dict
integer, intent(in), optional :: initial_capacity

The initial size of the internal array (default=11).

private subroutine dict_i4tuple_callstat_destroy(dict)

Deallocated the internal data-structures if the given dictionary. Caution: If the stored keys or values are pointers, their targets will not get deallocated by this routine.

Arguments

TypeIntentOptionalAttributesName
type(dict_i4tuple_callstat_type), intent(inout) :: dict

private subroutine dict_i4tuple_callstat_set(dict, key, value)

Stores, and possibly overwrites, a given value under a given key.

Arguments

TypeIntentOptionalAttributesName
type(dict_i4tuple_callstat_type), intent(inout) :: dict
integer(kind=int_4), intent(in), dimension(2):: key
type(call_stat_type), intent(in), POINTER:: value

private recursive subroutine set_hashed_i4tuple_callstat(dict, key, value, hash)

Common code used internally by dict_set() and change_capacity().

Arguments

TypeIntentOptionalAttributesName
type(dict_i4tuple_callstat_type), intent(inout) :: dict
integer(kind=int_4), intent(in), dimension(2):: key
type(call_stat_type), intent(in), POINTER:: value
integer(kind=int_8), intent(in) :: hash

private recursive subroutine change_capacity_i4tuple_callstat(dict, new_capacity)

Internal routine for changing the dictionary's capacity.

Arguments

TypeIntentOptionalAttributesName
type(dict_i4tuple_callstat_type), intent(inout) :: dict
integer, intent(in) :: new_capacity