open_hashmap_type Derived Type

type, public, extends(hashmap_type) :: open_hashmap_type

Type implementing an "open" hash map


Contents

Source Code


Finalization Procedures

final :: free_open_map

  • private interface free_open_map()

    Arguments

    None

Type-Bound Procedures

procedure, public, non_overridable, pass(map) :: calls

  • private pure function calls(map)

    Returns the number of subroutine calls on an open hash map (Specifications)

    Read more…

    Arguments

    TypeIntentOptionalAttributesName
    class(hashmap_type), intent(in) :: map

    Return Value integer(kind=int_calls)

procedure, public, non_overridable, pass(map) :: entries

  • private pure function entries(map)

    Returns the number of entries in a hash map (Specifications)

    Read more…

    Arguments

    TypeIntentOptionalAttributesName
    class(hashmap_type), intent(in) :: map

    Return Value integer(kind=int_index)

procedure, public :: get_all_keys => get_all_open_keys

  • interface

    private module module subroutine get_all_open_keys(map, all_keys)

    Returns all the keys contained in a hashmap Arguments: map - an open hash map all_keys - all the keys contained in a hash map

    Arguments

    TypeIntentOptionalAttributesName
    class(open_hashmap_type), intent(in) :: map
    type(key_type), intent(out), allocatable:: all_keys(:)

procedure, public :: get_other_data => get_other_open_data

  • interface

    private module module subroutine get_other_open_data(map, key, other, exists)

    Returns the other data associated with the inverse table index Arguments: map - an open hash table key - the key associated with a map entry other - the other data associated with the key exists - a logical flag indicating whether an entry with that key exists

    Arguments

    TypeIntentOptionalAttributesName
    class(open_hashmap_type), intent(inout) :: map
    type(key_type), intent(in) :: key
    type(other_type), intent(out) :: other
    logical, intent(out), optional :: exists

procedure, public :: init => init_open_map

  • interface

    private module module subroutine init_open_map(map, hasher, slots_bits, status)

    Routine to allocate an empty map with HASHER as the hash function, 2SLOTS_BITS initial SIZE(map % slots), and SIZE(map % slots) limited to a maximum of 2MAX_BITS. All fields are initialized. Arguments: map - the open hash maap to be initialized hasher - the hash function to be used to map keys to slots slots_bits - the number of bits used to map to the slots status - an integer error status flag with the allowed values: success - no problems were found alloc_fault - map % slots or map % inverse could not be allocated array_size_error - slots_bits is less than default_bitd or greater than max_bits

    Arguments

    TypeIntentOptionalAttributesName
    class(open_hashmap_type), intent(out) :: map
    procedure(hasher_fun) :: hasher
    integer, intent(in), optional :: slots_bits
    integer(kind=int32), intent(out), optional :: status

procedure, public :: key_test => open_key_test

  • interface

    private module module subroutine open_key_test(map, key, present)

    Returns a logical flag indicating whether KEY exists in the hash map Arguments: map - the hash map of interest key - the key of interest present - a logical flag indicating whether KEY exists in the hash map

    Arguments

    TypeIntentOptionalAttributesName
    class(open_hashmap_type), intent(inout) :: map
    type(key_type), intent(in) :: key
    logical, intent(out) :: present

procedure, public :: loading => open_loading

  • interface

    private pure module module function open_loading(map)

    Returns the number of entries relative to slots in a hash map Arguments: map - an open hash map

    Arguments

    TypeIntentOptionalAttributesName
    class(open_hashmap_type), intent(in) :: map

    Return Value real

procedure, public :: map_entry => map_open_entry

  • interface

    private module module subroutine map_open_entry(map, key, other, conflict)

    Inserts an entry into the hash table Arguments: map - the hash table of interest key - the key identifying the entry other - other data associated with the key conflict - logical flag indicating whether the entry key conflicts with an existing key

    Arguments

    TypeIntentOptionalAttributesName
    class(open_hashmap_type), intent(inout) :: map
    type(key_type), intent(in) :: key
    type(other_type), intent(in), optional :: other
    logical, intent(out), optional :: conflict

procedure, public, non_overridable, pass(map) :: map_probes

  • private pure function map_probes(map)

    Returns the total number of table probes on a hash map (Specifications)

    Read more…

    Arguments

    TypeIntentOptionalAttributesName
    class(hashmap_type), intent(in) :: map

    Return Value integer(kind=int_calls)

procedure, public, non_overridable, pass(map) :: num_slots

  • private pure function num_slots(map)

    Returns the number of allocated slots in a hash map (Specifications)

    Read more…

    Arguments

    TypeIntentOptionalAttributesName
    class(hashmap_type), intent(in) :: map

    Return Value integer(kind=int_index)

procedure, public :: rehash => rehash_open_map

  • interface

    private module module subroutine rehash_open_map(map, hasher)

    Changes the hashing method of the table entries to that of HASHER. Arguments: map the table to be rehashed hasher the hasher function to be used for the table

    Arguments

    TypeIntentOptionalAttributesName
    class(open_hashmap_type), intent(inout) :: map
    procedure(hasher_fun) :: hasher

procedure, public :: remove => remove_open_entry

  • interface

    private module module subroutine remove_open_entry(map, key, existed)

    Remove the entry, if any, that has the key Arguments: map - the table from which the entry is to be removed key - the key to an entry existed - a logical flag indicating whether an entry with the key was present in the original map

    Arguments

    TypeIntentOptionalAttributesName
    class(open_hashmap_type), intent(inout) :: map
    type(key_type), intent(in) :: key
    logical, intent(out), optional :: existed

procedure, public :: set_other_data => set_other_open_data

  • interface

    private module module subroutine set_other_open_data(map, key, other, exists)

    Change the other data associated with the key Arguments: map - the map with the entry of interest key - the key to the entry inthe map other - the new data to be associated with the key exists - a logical flag indicating whether the key is already entered in the map

    Arguments

    TypeIntentOptionalAttributesName
    class(open_hashmap_type), intent(inout) :: map
    type(key_type), intent(in) :: key
    type(other_type), intent(in) :: other
    logical, intent(out), optional :: exists

procedure, public, non_overridable, pass(map) :: slots_bits

  • private pure function slots_bits(map)

    Returns the number of bits used to specify the number of allocated slots in a hash map (Specifications)

    Read more…

    Arguments

    TypeIntentOptionalAttributesName
    class(hashmap_type), intent(in) :: map

    Return Value integer

procedure, public :: total_depth => total_open_depth

  • interface

    private module module function total_open_depth(map) result(total_depth)

    Returns the total number of ones based offsets of slot entries from their slot index for a hash map Arguments: map - an open hash map

    Arguments

    TypeIntentOptionalAttributesName
    class(open_hashmap_type), intent(in) :: map

    Return Value integer(kind=int64)

Source Code

    type, extends(hashmap_type) :: open_hashmap_type
!! Version: Experimental
!!
!! Type implementing an "open" hash map
        private
        integer(int_index) :: index_mask = 2_int_index**default_bits-1
!! Mask used in linear addressing
        type(open_map_entry_pool), pointer    :: cache => null()
!! Pool of allocated open_map_entry_type objects
        type(open_map_entry_list), pointer    :: free_list => null()
!! free list of map entries
        type(open_map_entry_ptr), allocatable  :: inverse(:)
!! Array of bucket lists (inverses) Note max_elts=size(inverse)
        integer(int_index), allocatable        :: slots(:)
!! Array of indices to the inverse Note # slots=size(slots)
    contains
        procedure :: get_all_keys => get_all_open_keys
        procedure :: get_other_data => get_other_open_data
        procedure :: init => init_open_map
        procedure :: loading => open_loading
        procedure :: map_entry => map_open_entry
        procedure :: rehash => rehash_open_map
        procedure :: remove => remove_open_entry
        procedure :: set_other_data => set_other_open_data
        procedure :: total_depth => total_open_depth
        procedure :: key_test => open_key_test
        final     :: free_open_map
    end type open_hashmap_type