hash_map_keys Function

private function hash_map_keys(this) result(res)

All keys, in insertion order.

Fortran arrays are not ragged, so every element has the same length: keys shorter than the longest one are blank-padded on the right. That padding is lossy for keys that themselves end in blanks, and a zero-length key comes back as a blank string. Use at() when the exact key text matters. The result is zero-sized for an empty map.

Type Bound

hash_map_t

Arguments

Type IntentOptional Attributes Name
class(hash_map_t), intent(in) :: this

Return Value character(len=:), allocatable, (:)


Calls

proc~~hash_map_keys~~CallsGraph proc~hash_map_keys hash_map_t%hash_map_keys proc~entry_key entry_key proc~hash_map_keys->proc~entry_key

Variables

Type Visibility Attributes Name Initial
integer(kind=default_int), private :: i
integer(kind=default_int), private :: longest

Source Code

   function hash_map_keys(this) result(res)
      !! All keys, in insertion order.
      !!
      !! Fortran arrays are not ragged, so every element has the same length:
      !! keys shorter than the longest one are blank-padded on the right. That
      !! padding is lossy for keys that themselves end in blanks, and a
      !! zero-length key comes back as a blank string. Use `at()` when the
      !! exact key text matters. The result is zero-sized for an empty map.
      class(hash_map_t), intent(in) :: this
      character(len=:), allocatable :: res(:)

      integer(default_int) :: i, longest

      longest = 1
      do i = 1, this%n_entries
         if (this%key_size(i) > longest) longest = this%key_size(i)
      end do

      allocate (character(len=longest) :: res(this%n_entries))
      do i = 1, this%n_entries
         res(i) = entry_key(this, i)
      end do
   end function hash_map_keys