node Derived Type

type, public :: node

a node in the linked list. This is the container to the unlimited polymorphic value variable.


Inherited by

type~~node~~InheritedByGraph type~node node type~node->type~node next, previous type~list list type~list->type~node head, tail

Components

Type Visibility Attributes Name Initial
class(*), private, allocatable :: key

the key (can be integer, string, or key_class)

class(*), private, pointer :: value => null()

the data to hold

logical, private :: destroy_on_delete = .true.

if true, value pointer is deallocated when it is removed from the list, or the list is destroyed. If false, it is only nullified.

type(node), private, pointer :: next => null()

the next one in the list

type(node), private, pointer :: previous => null()

the previous one in the list


Type-Bound Procedures

procedure, public :: destroy => destroy_node_data

deallocate value

  • private impure elemental subroutine destroy_node_data(me)

    destroy the data in the node.

    Arguments

    Type IntentOptional Attributes Name
    class(node), intent(inout) :: me

procedure, public :: get_data => get_node_data

get data from a node

  • private subroutine get_node_data(me, value)

    Get the data from a node

    Arguments

    Type IntentOptional Attributes Name
    class(node), intent(in) :: me
    class(*), intent(out), pointer :: value

Source Code

    type,public :: node

        !! a node in the linked list. This is the container to
        !! the unlimited polymorphic `value` variable.

        private

        class(*),allocatable :: key  !! the key (can be integer, string, or [[key_class]])

        class(*),pointer :: value => null()  !! the data to hold

        logical :: destroy_on_delete = .true. !! if true, value pointer is deallocated
                                              !! when it is removed from the list,
                                              !! or the list is destroyed. If false,
                                              !! it is only nullified.

        type(node),pointer :: next     => null()  !! the next one in the list
        type(node),pointer :: previous => null()  !! the previous one in the list

        contains

        private

        procedure,public :: destroy  => destroy_node_data  !! deallocate value
        procedure,public :: get_data => get_node_data      !! get data from a node

    end type node