traverse_list Subroutine

private subroutine traverse_list(me, iterator)

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

Type Bound

list

Arguments

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

the function to call for each node.


Called by

proc~~traverse_list~~CalledByGraph proc~traverse_list list%traverse_list proc~has_key list%has_key proc~has_key->proc~traverse_list proc~traverse list%traverse proc~traverse->proc~traverse_list

Source Code

    subroutine traverse_list(me,iterator)

    implicit none

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

    type(node),pointer :: p
    logical :: done

    done = .false.
    p => me%head

    do
        if (associated(p)) then
            call iterator(p,done)
            if (done) exit
            p => p%next
        else
            exit ! done
        end if
    end do

    end subroutine traverse_list