堆栈
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer, | public | :: | len | = | 0 |
number of nodes in the stack |
push an item to the stack
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(stack), | intent(inout) | :: | self | |||
class(*), | intent(in) | :: | item |
pop an item from the stack
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(stack), | intent(inout) | :: | self | |||
class(*), | intent(out), | optional, | allocatable | :: | item |
Get an stack_iterator for the stack
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(stack), | intent(in) | :: | self |
Clear the stack
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(stack), | intent(inout) | :: | self |
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