bidir_node_mod Module

module~~bidir_node_mod~~UsesGraph module~bidir_node_mod bidir_node_mod module~linked_node_mod linked_node_mod module~linked_node_mod->module~bidir_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 two other (the next and previous) nodes, allowing a chain to be formed. This can be used to, for example, build a doubly-linked lists.

It is not anticipated that the bidir_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.


Derived Types

type, public, extends(linked_node) :: bidir_node

Components

TypeVisibility AttributesNameInitial
class(bidir_node), private, pointer:: prev=> null()

Type-Bound Procedures

procedure, public :: has_prev
procedure, public :: get_prev
procedure, public :: set_prev
procedure, public :: unset_prev

Description

A node which, in addition to holding a value, points at two other (the previous and next) bidir_node objects or objects of a descendent type. This type can be built up into a chain, allowing a doubly-linked list to be formed.


Functions

private elemental function has_prev(this)

Arguments

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

Return Value logical

Description

Author
Chris MacMackin
Date
February 2016

Returns whether or not this node points to a previous one, forming a chain in the backwards direction.

private function get_prev(this)

Arguments

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

Return Value class(bidir_node), pointer

Description

Author
Chris MacMackin
Date
February 2016

Returns a pointer to the previous node in the chain. If this node does not point at a previous one one, then a null pointer is returned.


Subroutines

private subroutine set_prev(this, new_prev, deallocate_old)

Arguments

Type IntentOptional AttributesName
class(bidir_node), intent(inout) :: this
class(bidir_node), intent(in), pointer:: new_prev

The node which will now be previous in the chain.

logical, intent(in), optional :: deallocate_old

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

Description

Author
Chris MacMackin
Date
February 2016

Sets the pointer to the previous node in the chain. If this node already points to a previous one, the pointer will, by default, be nullified. This may result in a memory leak. Optionally, by setting deallocate_old=.true., the previous 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 previous node. The new previous node will not automatically be set to have this one as the next, with the same rules applied to deallocation.

private subroutine unset_prev(this, deallocate_old)

Arguments

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

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

Description

Author
Chris MacMackin
Date
February 2016

Unsets the pointer to the previous 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 previous node (and all previous nodes it points to) can be deallocated. This may result in a segfault if another part of the program tries to access the former previous node.