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

Public Member Functions

subroutine dchashput0 (hashv, key, value)

Detailed Description

Definition at line 194 of file dc_hash.f90.

Member Function/Subroutine Documentation

◆ dchashput0()

subroutine dc_hash::dchashput::dchashput0 ( type(hash), intent(inout) hashv,
character(*), intent(in) key,
character(*), intent(in) value )

ハッシュにキーと値を付加

hashv のキー key に値 value を関連付けます. key が既に存在する場合は, 関連する値を更新します.

Parameters
[in,out]hashvハッシュ変数
[in]keyキー文字列
[in]valueキーに関連付ける値文字列

Definition at line 276 of file dc_hash.f90.

277 implicit none
278 type(HASH), intent(inout) :: hashv
279 character(*), intent(in) :: key, value
280 type(HASH_INTERNAL), pointer :: hash_table_tmp(:) => null()
281 integer :: table_size, new_index, i
282 logical :: found
283 character(STRING) :: search_value
284 continue
285 call dchashget(hashv, key, search_value, found)
286 if (.not. found) then
287 table_size = dchashnumber(hashv)
288 if (table_size > 0) then
289 allocate(hash_table_tmp(table_size))
290 hash_table_tmp = hashv % hash_table
291 deallocate(hashv % hash_table)
292 allocate(hashv % hash_table(table_size + 1))
293 hashv % hash_table(1:table_size) = hash_table_tmp(1:table_size)
294 deallocate(hash_table_tmp)
295 new_index = table_size + 1
296 else
297 allocate(hashv % hash_table(1))
298 new_index = 1
299 end if
300
301 hashv % hash_table(new_index) % key = key
302 hashv % hash_table(new_index) % value = value
303 else
304 do i = 1, size(hashv % hash_table)
305 if (trim(hashv % hash_table(i) % key) == trim(key)) then
306 hashv % hash_table(i) % value = value
307 end if
308 end do
309 end if
310

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