bidir_node Derived Type

type, public, extends(linked_node) :: bidir_node

type~~bidir_node~~InheritsGraph type~bidir_node bidir_node type~bidir_node->type~bidir_node prev type~linked_node linked_node type~linked_node->type~bidir_node type~linked_node->type~linked_node next type~node node type~node->type~linked_node type~container container type~container->type~node contents
Help


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.

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. As such, care must be taken when using certain methods (see below) to avoid memory leaks or segfaults.


Components

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

Type-Bound Procedures

procedure, public :: has_prev

  • 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.

procedure, public :: get_prev

  • 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.

procedure, public :: set_prev

  • 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.

procedure, public :: unset_prev

  • 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.

Source Code

  type, extends(linked_node), public :: bidir_node
    !* Author: Chris MacMackin
    !  Date: February 2016
    !
    ! 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.
    ! 
    ! 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. As such, care must
    ! be taken when using certain methods (see below) to avoid memory
    ! leaks or segfaults.
    !
    private
    class(bidir_node), pointer :: prev => null()
  contains
    procedure :: has_prev
    procedure :: get_prev
    procedure :: set_prev
    procedure :: unset_prev
  end type bidir_node