Loading...
Searching...
No Matches
dc_hash::delete Interface Reference

Public Member Functions

subroutine dchashdelete0 (hashv, key)

Detailed Description

Definition at line 174 of file dc_hash.f90.

Member Function/Subroutine Documentation

◆ dchashdelete0()

subroutine dc_hash::delete::dchashdelete0 ( type(hash), intent(inout) hashv,
character(*), intent(in), optional key )

Definition at line 361 of file dc_hash.f90.

362 !
363 ! *hashv* のキー *key* およびその関連する値を削除します.
364 ! *hashv* 内に *key* が見つからない場合には何もしません.
365 !
366 ! *key* が省略される場合には *hashv* 内の全てのキーと値を
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

The documentation for this interface was generated from the following file: