linked_node_mod Module

module~~linked_node_mod~~UsesGraph module~linked_node_mod linked_node_mod module~node_mod node_mod module~node_mod->module~linked_node_mod module~abstract_container_mod abstract_container_mod module~abstract_container_mod->module~node_mod iso_fortran_env iso_fortran_env iso_fortran_env->module~abstract_container_mod
Help

Implements a node which contains a pointer to another (the next) node, allowing a chain to be formed. This can be used to, for example, build linked lists.

It is not anticipated that the linked_node type, or any types extending it, will be handled directly by end users of FIAT; they are meant for internal use within this package.

Used By

module~~linked_node_mod~~UsedByGraph module~linked_node_mod linked_node_mod module~bidir_node_mod bidir_node_mod module~linked_node_mod->module~bidir_node_mod
Help

Derived Types

type, public, extends(node) :: linked_node

Components

TypeVisibility AttributesNameInitial
class(linked_node), private, pointer:: next=> null()

The next node in the chain.

Type-Bound Procedures

procedure, public :: has_next

Checks whether this node points to another one

procedure, public :: get_next

Returns the next node in the chain if it exists.

procedure, public :: set_next

Sets the next node in the chain.

procedure, public :: unset_next

Sets this node not to point at any others, severing the chain.

Description

A node which, in addition to holding a value, points at another (the next) linked_node or descendent type. This type can be built up into a chain, allowing a linked list to be formed.


Functions

private elemental function has_next(this)

Arguments

Type IntentOptional AttributesName
class(linked_node), intent(in) :: this

Return Value logical

Description

Author
Chris MacMackin
Date
February 2016

Returns whether or not this node points at another one, forming a chain.

private function get_next(this)

Arguments

Type IntentOptional AttributesName
class(linked_node), intent(in) :: this

Return Value class(linked_node), pointer

Description

Author
Chris MacMackin
Date
February 2016

Returns a pointer to the node which this ones points to, i.e. the next node in the chain. If this node does not point at another one, then a null pointer is returned.


Subroutines

private subroutine set_next(this, new_next, deallocate_old)

Arguments

Type IntentOptional AttributesName
class(linked_node), intent(inout) :: this
class(linked_node), intent(in), pointer:: new_next

The node which will now be next in the chain.

logical, intent(in), optional :: deallocate_old

Whether to deallocate (rather than just nullify) any existing subsequent nodes in the chain. Defaults to .false..

Description

Author
Chris MacMackin
Date
February 2016

Sets the node which this one points to (i.e. sets the next node in the chain). If this node already points to another one, the pointer will, by default, be nullified. This may result in a memory leak. Optionally, by setting deallocate_old=.true., the next node (and all nodes it points to) can be deallocated. This may result in a segfault if another part of the program tries to access the former next node.

private subroutine unset_next(this, deallocate_old)

Arguments

Type IntentOptional AttributesName
class(linked_node), intent(inout) :: this
logical, intent(in), optional :: deallocate_old

Whether to deallocate (rather than just nullify) any existing subsequent nodes in the chain. Defaults to .false..

Description

Author
Chris MacMackin
Date
February 2016

Unsets the pointer to the next node in the chain, severing it. By default, the pointer is only nullified. This may result in a memory leak. Optionally, by setting deallocate_old=.true., the next node (and all nodes it points to) can be deallocated. This may result in a segfault if another part of the program tries to access the former next node.