Return a pointer to a node in the dictionary.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(dictionary), | intent(in) | :: | self | The dictionary. |
||
class(*), | intent(in) | :: | key | The key. |
Pointer to node queried.
function node(self, key) result(p)
!---------------------------------------------------------------------------------------------------------------------------------
!< Return a pointer to a node in the dictionary.
!---------------------------------------------------------------------------------------------------------------------------------
class(dictionary), intent(in) :: self !< The dictionary.
class(*), intent(in) :: key !< The key.
type(dictionary_node), pointer :: p !< Pointer to node queried.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
p => null()
call self%traverse_iterator(iterator=key_iterator_search)
!---------------------------------------------------------------------------------------------------------------------------------
contains
subroutine key_iterator_search(node, done)
!-------------------------------------------------------------------------------------------------------------------------------
!< Iterator procedure for searching a key.
!-------------------------------------------------------------------------------------------------------------------------------
type(dictionary_node), pointer, intent(in) :: node !< Actual node pointer in the dictionary.
logical, intent(out) :: done !< Flag to set to true to stop traversing.
!-------------------------------------------------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------------------------------------------------
done = .false.
if (node%has_key()) done = node%key==key
if (done) then
p => node
endif
!-------------------------------------------------------------------------------------------------------------------------------
endsubroutine key_iterator_search
endfunction node