fhash_sll Module

Implements singly-linked list (sll) node with generic data container



Contents


Derived Types

type, public ::  fhash_node_t

Node type for hash table singly linked list

Components

Type Visibility Attributes Name Initial
class(fhash_key_t), public, allocatable :: key
type(fhash_container_t), public :: value
type(fhash_node_t), public, pointer :: next => NULL()

Functions

public function node_depth(node) result(depth)

Determine depth of SLL

Arguments

Type IntentOptional Attributes Name
type(fhash_node_t), intent(in), target :: node

Node to check depth

Return Value integer


Subroutines

public recursive subroutine sll_push_node(node, key, value, pointer)

Append node to SLL

Arguments

Type IntentOptional Attributes Name
type(fhash_node_t), intent(inout) :: node

Node to which to add data

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

Key to add

class(*), intent(in), target :: value

Value to add

logical, intent(in), optional :: pointer

Store only a point if .true.

public subroutine sll_node_set(node, value, pointer)

Set container value in node

Arguments

Type IntentOptional Attributes Name
type(fhash_node_t), intent(inout) :: node

Node to which to add data

class(*), intent(in), target :: value

Value to set

logical, intent(in), optional :: pointer

Store only a pointer if .true.

public recursive subroutine sll_find_in(node, key, data, found)

Search for a node with a specific key. Returns a pointer to the 'data' component of the corresponding node. Pointer is not associated if node cannot be found

Arguments

Type IntentOptional Attributes Name
type(fhash_node_t), intent(in), target :: node

Node to search in

class(fhash_key_t) :: key

Key to look for

type(fhash_container_t), intent(out), pointer :: data

Pointer to value container if found. (Unassociated if the key is not found in node)

logical, intent(out), optional :: found

public recursive subroutine sll_get_at(node, depth, key, data, found)

Return a node at a specific depth in the sll

Arguments

Type IntentOptional Attributes Name
type(fhash_node_t), intent(in), target :: node

Node to search in

integer, intent(in) :: depth

Node depth to access

class(fhash_key_t), intent(out), allocatable :: key

Key of found item (Unallocated if no node is found at specified depth)

type(fhash_container_t), intent(out), pointer :: data

Pointer to value container if found. (Unassociated if no node is found at specified depth)

logical, intent(out), optional :: found

public recursive subroutine sll_remove(node, key, found, parent_node)

Search for a node with a specific key and remove

Arguments

Type IntentOptional Attributes Name
type(fhash_node_t), intent(inout) :: node

Node to remove from

class(fhash_key_t) :: key

Key to remove

logical, intent(out), optional :: found

Indicates if the key was found in node and removed

type(fhash_node_t), intent(inout), optional :: parent_node

Used internally

public recursive subroutine sll_clean(node)

Deallocate node components and those of its children

Arguments

Type IntentOptional Attributes Name
type(fhash_node_t), intent(inout) :: node

Node to search in