find_entry Function

private function find_entry(this, key) result(entry)

Index of key in the insertion-order table, or 0 when absent.

Arguments

Type IntentOptional Attributes Name
class(hash_map_t), intent(in) :: this
character(len=*), intent(in) :: key

Return Value integer(kind=default_int)


Calls

proc~~find_entry~~CallsGraph proc~find_entry find_entry proc~home_bucket home_bucket proc~find_entry->proc~home_bucket proc~key_matches key_matches proc~find_entry->proc~key_matches interface~fnv_1a_hash fnv_1a_hash proc~home_bucket->interface~fnv_1a_hash

Called by

proc~~find_entry~~CalledByGraph proc~find_entry find_entry proc~hash_map_get hash_map_t%hash_map_get proc~hash_map_get->proc~find_entry proc~hash_map_has_key hash_map_t%hash_map_has_key proc~hash_map_has_key->proc~find_entry proc~hash_map_insert hash_map_t%hash_map_insert proc~hash_map_insert->proc~find_entry proc~hash_map_remove hash_map_t%hash_map_remove proc~hash_map_remove->proc~find_entry

Variables

Type Visibility Attributes Name Initial
integer(kind=default_int), private :: bucket
integer(kind=default_int), private :: candidate
integer(kind=default_int), private :: probe

Source Code

   function find_entry(this, key) result(entry)
      !! Index of `key` in the insertion-order table, or 0 when absent.
      class(hash_map_t), intent(in) :: this
      character(len=*), intent(in) :: key
      integer(default_int) :: entry

      integer(default_int) :: bucket, probe, candidate

      entry = 0
      if (this%n_buckets == 0) return

      bucket = home_bucket(this, key)
      do probe = 1, this%n_buckets
         candidate = this%buckets(bucket)
         if (candidate == BUCKET_EMPTY) return
         if (key_matches(this, candidate, key)) then
            entry = candidate
            return
         end if
         bucket = bucket + 1
         if (bucket > this%n_buckets) bucket = 1
      end do
   end function find_entry