hash_map_at Subroutine

private subroutine hash_map_at(this, position, key, value, err)

Fetch the entry at position in the iteration order, counting from 1. This is the exact-fidelity iteration accessor: key comes back with the key’s true length, trailing blanks included.

An out-of-range position yields key == "", value == 0 and ERROR_VALIDATION in err when it is present.

Type Bound

hash_map_t

Arguments

Type IntentOptional Attributes Name
class(hash_map_t), intent(in) :: this
integer(kind=default_int), intent(in) :: position
character(len=:), intent(out), allocatable :: key
integer(kind=int64), intent(out) :: value
type(error_t), intent(out), optional :: err

Calls

proc~~hash_map_at~~CallsGraph proc~hash_map_at hash_map_t%hash_map_at proc~entry_key entry_key proc~hash_map_at->proc~entry_key proc~error_set error_t%error_set proc~hash_map_at->proc~error_set

Source Code

   subroutine hash_map_at(this, position, key, value, err)
      !! Fetch the entry at `position` in the iteration order, counting from 1.
      !! This is the exact-fidelity iteration accessor: `key` comes back with
      !! the key's true length, trailing blanks included.
      !!
      !! An out-of-range `position` yields `key == ""`, `value == 0` and
      !! `ERROR_VALIDATION` in `err` when it is present.
      class(hash_map_t), intent(in) :: this
      integer(default_int), intent(in) :: position
      character(len=:), allocatable, intent(out) :: key
      integer(int64), intent(out) :: value
      type(error_t), intent(out), optional :: err

      if (position < 1 .or. position > this%n_entries) then
         key = ""
         value = 0_int64
         if (present(err)) then
            call err%set(ERROR_VALIDATION, "pic_hash_map: iteration index out of range")
         end if
         return
      end if

      key = entry_key(this, position)
      value = this%entry_value(position)
   end subroutine hash_map_at