Traverse dictionary from head to tail calling the iterator procedure.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(dictionary), | intent(in) | :: | self | The dictionary. |
||
procedure(iterator_interface) | :: | iterator | The iterator procedure to call for each node. |
subroutine traverse_iterator(self, iterator)
!---------------------------------------------------------------------------------------------------------------------------------
!< Traverse dictionary from head to tail calling the iterator procedure.
!---------------------------------------------------------------------------------------------------------------------------------
class(dictionary), intent(in) :: self !< The dictionary.
procedure(iterator_interface) :: iterator !< The iterator procedure to call for each node.
type(dictionary_node), pointer :: p !< Pointer to scan the dictionary.
logical :: done !< Flag to set to true to stop traversing.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
done = .false.
p => self%head
do
if (associated(p)) then
call iterator(node=p, done=done)
if (done) exit
p => p%next
else
exit
endif
enddo
!---------------------------------------------------------------------------------------------------------------------------------
endsubroutine traverse_iterator