362
363
364
365
366
367
368
369 implicit none
370 type(HASH), intent(inout) :: hashv
371 character(*), intent(in), optional :: key
372 type(HASH_INTERNAL), pointer :: hash_table_tmp(:) => null()
373 integer :: table_size, i, j
374 logical :: found
375 character(STRING) :: search_value
376 continue
377 if (present(key)) then
378 call dchashget(hashv, key, search_value, found)
379 table_size = dchashnumber(hashv)
380 if (found .and. table_size > 1) then
381 allocate(hash_table_tmp(table_size))
382 hash_table_tmp = hashv % hash_table
383 deallocate(hashv % hash_table)
384 allocate(hashv % hash_table(table_size - 1))
385 j = 1
386 do i = 1, table_size
387 if (trim(hash_table_tmp(i) % key) /= trim(key)) then
388 hashv % hash_table(j) % key = hash_table_tmp(i) % key
389 hashv % hash_table(j) % value = hash_table_tmp(i) % value
390 j = j + 1
391 end if
392 end do
393
394 deallocate(hash_table_tmp)
395 elseif (found .and. table_size == 1) then
396 deallocate(hashv % hash_table)
397 end if
398 else
399 if (associated(hashv % hash_table)) deallocate(hashv % hash_table)
400 end if
401