dlist Module

Doubly-linked list with polymorphic element storage. Iterate with iterate / reverse_iterate, or access by index with get. Abstract base for list element data. Extend this type to store custom data. Node holding a single integer value. Node holding a single real(8) value. Node holding a real(8) rank-1 array. Node holding a real(8) rank-2 array. Node holding an allocatable character string. Construct an integer node. Construct a real(8) scalar node. Construct a real(8) rank-1 array node. Construct a real(8) rank-2 array node. Construct a character node. Generic node constructor — dispatches on argument type. Visitor procedure signature for iterate / reverse_iterate. Set ok = .false. to stop iteration early.


Used by


Interfaces

public interface int_node

public interface real_node

public interface real_a_node

public interface real_m_node

public interface char_node

public interface make_node

interface

  • public module function make_int_node(v) result(n)

    Arguments

    Type IntentOptional Attributes Name
    integer, intent(in) :: v

    Return Value type(dlist_node_integer)

interface

  • public module function make_real_node(v) result(n)

    Arguments

    Type IntentOptional Attributes Name
    real(kind=8), intent(in) :: v

    Return Value type(dlist_node_real)

interface

  • public module function make_real_a_node(v) result(n)

    Arguments

    Type IntentOptional Attributes Name
    real(kind=8), intent(in) :: v(:)

    Return Value type(dlist_node_real_a)

interface

  • public module function make_real_m_node(v) result(n)

    Arguments

    Type IntentOptional Attributes Name
    real(kind=8), intent(in) :: v(:,:)

    Return Value type(dlist_node_real_m)

interface

  • public module function make_char_node(v) result(n)

    Arguments

    Type IntentOptional Attributes Name
    character(len=*), intent(in) :: v

    Return Value type(dlist_node_char)

interface

Apply f to each element in forward order. Returns .true. if all elements were visited (i.e. f never set ok=.false.). Insert data at 1-based idx, shifting later elements right. Out-of-range low values prepend; out-of-range high values append. Remove the element at 1-based idx. Silently does nothing if idx is out-of-range. Apply f to each element in reverse order. Print list contents to stdout. Append data to the tail of the list. Number of elements in the list. Remove all elements. Index-based accessor (1-based). Returns an allocatable polymorphic copy of the node data. Unallocated if idx is out of range — check allocated(node) before select type.

  • public module function iterate_ll(this, f) result(r)

    Arguments

    Type IntentOptional Attributes Name
    class(dlist_t), intent(inout), target :: this
    procedure(command_fun) :: f

    Return Value logical

interface

Apply f to each element in forward order. Returns .true. if all elements were visited (i.e. f never set ok=.false.). Insert data at 1-based idx, shifting later elements right. Out-of-range low values prepend; out-of-range high values append. Remove the element at 1-based idx. Silently does nothing if idx is out-of-range. Apply f to each element in reverse order. Print list contents to stdout. Append data to the tail of the list. Number of elements in the list. Remove all elements. Index-based accessor (1-based). Returns an allocatable polymorphic copy of the node data. Unallocated if idx is out of range — check allocated(node) before select type.

  • public module function reverse_iterate_ll(this, f) result(r)

    Arguments

    Type IntentOptional Attributes Name
    class(dlist_t), intent(inout), target :: this
    procedure(command_fun) :: f

    Return Value logical

interface

Apply f to each element in forward order. Returns .true. if all elements were visited (i.e. f never set ok=.false.). Insert data at 1-based idx, shifting later elements right. Out-of-range low values prepend; out-of-range high values append. Remove the element at 1-based idx. Silently does nothing if idx is out-of-range. Apply f to each element in reverse order. Print list contents to stdout. Append data to the tail of the list. Number of elements in the list. Remove all elements. Index-based accessor (1-based). Returns an allocatable polymorphic copy of the node data. Unallocated if idx is out of range — check allocated(node) before select type.

  • public module function size_ll(lst)

    Arguments

    Type IntentOptional Attributes Name
    class(dlist_t), intent(in) :: lst

    Return Value integer

interface

Apply f to each element in forward order. Returns .true. if all elements were visited (i.e. f never set ok=.false.). Insert data at 1-based idx, shifting later elements right. Out-of-range low values prepend; out-of-range high values append. Remove the element at 1-based idx. Silently does nothing if idx is out-of-range. Apply f to each element in reverse order. Print list contents to stdout. Append data to the tail of the list. Number of elements in the list. Remove all elements. Index-based accessor (1-based). Returns an allocatable polymorphic copy of the node data. Unallocated if idx is out of range — check allocated(node) before select type.

  • public module function get_ll(this, idx) result(node)

    Arguments

    Type IntentOptional Attributes Name
    class(dlist_t), intent(in) :: this
    integer, intent(in) :: idx

    Return Value class(dlist_node_data_t), allocatable

interface

Apply f to each element in forward order. Returns .true. if all elements were visited (i.e. f never set ok=.false.). Insert data at 1-based idx, shifting later elements right. Out-of-range low values prepend; out-of-range high values append. Remove the element at 1-based idx. Silently does nothing if idx is out-of-range. Apply f to each element in reverse order. Print list contents to stdout. Append data to the tail of the list. Number of elements in the list. Remove all elements. Index-based accessor (1-based). Returns an allocatable polymorphic copy of the node data. Unallocated if idx is out of range — check allocated(node) before select type.

  • public module subroutine insert_ll(lst, idx, data)

    Arguments

    Type IntentOptional Attributes Name
    class(dlist_t), intent(inout) :: lst
    integer, intent(in) :: idx
    class(dlist_node_data_t), intent(in) :: data

interface

Apply f to each element in forward order. Returns .true. if all elements were visited (i.e. f never set ok=.false.). Insert data at 1-based idx, shifting later elements right. Out-of-range low values prepend; out-of-range high values append. Remove the element at 1-based idx. Silently does nothing if idx is out-of-range. Apply f to each element in reverse order. Print list contents to stdout. Append data to the tail of the list. Number of elements in the list. Remove all elements. Index-based accessor (1-based). Returns an allocatable polymorphic copy of the node data. Unallocated if idx is out of range — check allocated(node) before select type.

  • public module subroutine remove_ll(lst, idx)

    Arguments

    Type IntentOptional Attributes Name
    class(dlist_t), intent(inout) :: lst
    integer, intent(in) :: idx

interface

Apply f to each element in forward order. Returns .true. if all elements were visited (i.e. f never set ok=.false.). Insert data at 1-based idx, shifting later elements right. Out-of-range low values prepend; out-of-range high values append. Remove the element at 1-based idx. Silently does nothing if idx is out-of-range. Apply f to each element in reverse order. Print list contents to stdout. Append data to the tail of the list. Number of elements in the list. Remove all elements. Index-based accessor (1-based). Returns an allocatable polymorphic copy of the node data. Unallocated if idx is out of range — check allocated(node) before select type.

  • public module subroutine print_ll(lst)

    Arguments

    Type IntentOptional Attributes Name
    class(dlist_t), intent(in) :: lst

interface

Apply f to each element in forward order. Returns .true. if all elements were visited (i.e. f never set ok=.false.). Insert data at 1-based idx, shifting later elements right. Out-of-range low values prepend; out-of-range high values append. Remove the element at 1-based idx. Silently does nothing if idx is out-of-range. Apply f to each element in reverse order. Print list contents to stdout. Append data to the tail of the list. Number of elements in the list. Remove all elements. Index-based accessor (1-based). Returns an allocatable polymorphic copy of the node data. Unallocated if idx is out of range — check allocated(node) before select type.

  • public module subroutine append_ll(lst, data)

    Arguments

    Type IntentOptional Attributes Name
    class(dlist_t), intent(inout) :: lst
    class(dlist_node_data_t), intent(in) :: data

interface

Apply f to each element in forward order. Returns .true. if all elements were visited (i.e. f never set ok=.false.). Insert data at 1-based idx, shifting later elements right. Out-of-range low values prepend; out-of-range high values append. Remove the element at 1-based idx. Silently does nothing if idx is out-of-range. Apply f to each element in reverse order. Print list contents to stdout. Append data to the tail of the list. Number of elements in the list. Remove all elements. Index-based accessor (1-based). Returns an allocatable polymorphic copy of the node data. Unallocated if idx is out of range — check allocated(node) before select type.

  • public module subroutine clear_ll(lst)

    Arguments

    Type IntentOptional Attributes Name
    class(dlist_t), intent(inout) :: lst

interface

Apply f to each element in forward order. Returns .true. if all elements were visited (i.e. f never set ok=.false.). Insert data at 1-based idx, shifting later elements right. Out-of-range low values prepend; out-of-range high values append. Remove the element at 1-based idx. Silently does nothing if idx is out-of-range. Apply f to each element in reverse order. Print list contents to stdout. Append data to the tail of the list. Number of elements in the list. Remove all elements. Index-based accessor (1-based). Returns an allocatable polymorphic copy of the node data. Unallocated if idx is out of range — check allocated(node) before select type.

  • public module subroutine assign_ll(lhs, rhs)

    Arguments

    Type IntentOptional Attributes Name
    class(dlist_t), intent(inout) :: lhs
    class(dlist_t), intent(in) :: rhs

interface

Apply f to each element in forward order. Returns .true. if all elements were visited (i.e. f never set ok=.false.). Insert data at 1-based idx, shifting later elements right. Out-of-range low values prepend; out-of-range high values append. Remove the element at 1-based idx. Silently does nothing if idx is out-of-range. Apply f to each element in reverse order. Print list contents to stdout. Append data to the tail of the list. Number of elements in the list. Remove all elements. Index-based accessor (1-based). Returns an allocatable polymorphic copy of the node data. Unallocated if idx is out of range — check allocated(node) before select type.

  • public module subroutine finalize_ll(lst)

    Arguments

    Type IntentOptional Attributes Name
    type(dlist_t), intent(inout) :: lst

Abstract Interfaces

abstract interface

  • public subroutine command_fun(command, ok)

    Arguments

    Type IntentOptional Attributes Name
    class(dlist_node_data_t), intent(in) :: command
    logical, intent(out) :: ok

Derived Types

type, public ::  dlist_t

Finalizations Procedures

final :: finalize_ll

Type-Bound Procedures

procedure, public :: iterate => iterate_ll

Apply a visitor to each element in order

procedure, public :: reverse_iterate => reverse_iterate_ll

Apply a visitor to each element in reverse

procedure, public :: print => print_ll

Print list contents to stdout

procedure, public :: append => append_ll

Append a node to the tail

procedure, public :: insert => insert_ll

Insert a node at 1-based index

procedure, public :: remove => remove_ll

Remove element at 1-based index

procedure, public :: size => size_ll

Number of elements

procedure, public :: clear => clear_ll

Remove all elements

procedure, public :: get => get_ll

Index-based accessor (1-based); unallocated if out of range

generic, public :: assignment(=) => assign_ll

type, public, abstract ::  dlist_node_data_t

type, public, extends(dlist_node_data_t) ::  dlist_node_integer

Components

Type Visibility Attributes Name Initial
integer, public :: data = 0

type, public, extends(dlist_node_data_t) ::  dlist_node_real

Components

Type Visibility Attributes Name Initial
real(kind=8), public :: data = 0.0d0

type, public, extends(dlist_node_data_t) ::  dlist_node_real_a

Components

Type Visibility Attributes Name Initial
real(kind=8), public, allocatable :: data(:)

type, public, extends(dlist_node_data_t) ::  dlist_node_real_m

Components

Type Visibility Attributes Name Initial
real(kind=8), public, allocatable :: data(:,:)

type, public, extends(dlist_node_data_t) ::  dlist_node_char

Components

Type Visibility Attributes Name Initial
character(len=:), public, allocatable :: data

type, public ::  dlist_node_t