traverse Subroutine

private subroutine traverse(me, iterator)

traverse list from head to tail, and call the iterator function for each key.

Type Bound

list

Arguments

Type IntentOptional Attributes Name
class(list), intent(inout) :: me
procedure(key_iterator) :: iterator

the function to call for each node.


Calls

proc~~traverse~~CallsGraph proc~traverse list%traverse proc~traverse_list list%traverse_list proc~traverse->proc~traverse_list

Source Code

    subroutine traverse(me,iterator)

    implicit none

    class(list),intent(inout) :: me
    procedure(key_iterator)  :: iterator  !! the function to call for each node.

    call me%traverse_list(key_iterator_wrapper)

    contains

        subroutine key_iterator_wrapper(me,done)

        !! for calling the user-specified key_iterator function.

        implicit none

        type(node),pointer  :: me
        logical,intent(out) :: done !! set to true to stop traversing

        call iterator(me%key,me%value,done)

        end subroutine key_iterator_wrapper

    end subroutine traverse