stack Derived Type

type, public :: stack

堆栈


Contents

Source Code


Components

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

number of nodes in the stack


Type-Bound Procedures

procedure, public, :: push => stack_push

  • private pure subroutine stack_push(self, item)

    push an item to the stack

    Arguments

    Type IntentOptional Attributes Name
    class(stack), intent(inout) :: self
    class(*), intent(in) :: item

procedure, public, :: pop => stack_pop

  • private subroutine stack_pop(self, item)

    pop an item from the stack

    Arguments

    Type IntentOptional Attributes Name
    class(stack), intent(inout) :: self
    class(*), intent(out), optional, allocatable :: item

procedure, public, :: iterator

  • private function iterator(self) result(iter)

    Get an stack_iterator for the stack

    Arguments

    Type IntentOptional Attributes Name
    class(stack), intent(in) :: self

    Return Value type(stack_iterator)

procedure, public, :: clear => stack_clear

  • private pure subroutine stack_clear(self)

    Clear the stack

    Arguments

    Type IntentOptional Attributes Name
    class(stack), intent(inout) :: self

Source Code

    type stack
        private
        integer, public :: len = 0 !! number of nodes in the stack
        type(node), pointer :: head => null() !! head of the stack
        type(node), pointer :: tail => null() !! tail of the stack
    contains
        procedure :: push => stack_push
        procedure :: pop => stack_pop
        procedure :: iterator
        procedure :: clear => stack_clear
    end type stack