hash_map_clear Subroutine

private subroutine hash_map_clear(this)

Remove every entry but keep the allocated capacity, so that refilling the map does not have to reallocate. A cleared map iterates as empty and the next insert starts a fresh insertion order at position 1.

Type Bound

hash_map_t

Arguments

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

Source Code

   subroutine hash_map_clear(this)
      !! Remove every entry but keep the allocated capacity, so that refilling
      !! the map does not have to reallocate. A cleared map iterates as empty
      !! and the next `insert` starts a fresh insertion order at position 1.
      class(hash_map_t), intent(inout) :: this

      this%n_entries = 0
      this%pool_used = 0
      if (allocated(this%buckets)) this%buckets = BUCKET_EMPTY
   end subroutine hash_map_clear