gtool5 Fortran 90/95 ライブラリ 1.0.0-rc5
English
Loading...
Searching...
No Matches
dc_hash::dchashdelete Interface Reference

Public Member Functions

subroutine dchashdelete0 (hashv, key)

Detailed Description

Definition at line 218 of file dc_hash.f90.

Member Function/Subroutine Documentation

◆ dchashdelete0()

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

キーを与え, ハッシュ内の関連する値を削除

hashv のキー key およびその関連する値を削除します. hashv 内に key が見つからない場合には何もしません.

key が省略される場合には hashv 内の全てのキーと値を 削除します.

Parameters
[in,out]hashvハッシュ変数
[in]key削除するキー文字列 (省略可能)

Definition at line 582 of file dc_hash.f90.

583 implicit none
584 type(HASH), intent(inout) :: hashv
585 character(*), intent(in), optional :: key
586 type(HASH_INTERNAL), pointer :: hash_table_tmp(:) => null()
587 integer :: table_size, i, j
588 logical :: found
589 character(STRING) :: search_value
590 continue
591 if (present(key)) then
592 call dchashget(hashv, key, search_value, found)
593 table_size = dchashnumber(hashv)
594 if (found .and. table_size > 1) then
595 allocate(hash_table_tmp(table_size))
596 hash_table_tmp = hashv % hash_table
597 deallocate(hashv % hash_table)
598 allocate(hashv % hash_table(table_size - 1))
599 j = 1
600 do i = 1, table_size
601 if (trim(hash_table_tmp(i) % key) /= trim(key)) then
602 hashv % hash_table(j) % key = hash_table_tmp(i) % key
603 hashv % hash_table(j) % value = hash_table_tmp(i) % value
604 j = j + 1
605 end if
606 end do
607
608 deallocate(hash_table_tmp)
609 elseif (found .and. table_size == 1) then
610 deallocate(hashv % hash_table)
611 end if
612 else
613 if (associated(hashv % hash_table)) deallocate(hashv % hash_table)
614 end if
615

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