110 integer :: search_index = 0
115 character(STRING) :: key
116 character(STRING) :: value
185 type(
hash),
intent(inout) :: hashv
186 character(*),
intent(in) :: key, value
188 integer :: table_size, new_index, i
190 character(STRING) :: search_value
192 call dchashget(hashv, key, search_value, found)
193 if (.not. found)
then 195 if (table_size > 0)
then 196 allocate(hash_table_tmp(table_size))
197 hash_table_tmp = hashv % hash_table
198 deallocate(hashv % hash_table)
199 allocate(hashv % hash_table(table_size + 1))
200 hashv % hash_table(1:table_size) = hash_table_tmp(1:table_size)
201 deallocate(hash_table_tmp)
202 new_index = table_size + 1
204 allocate(hashv % hash_table(1))
208 hashv % hash_table(new_index) % key = key
209 hashv % hash_table(new_index) % value =
value 211 do i = 1,
size(hashv % hash_table)
212 if (trim(hashv % hash_table(i) % key) == trim(key))
then 213 hashv % hash_table(i) % value =
value 226 type(
hash),
intent(in) :: hashv
229 if (
associated(hashv % hash_table))
then 230 result =
size(hashv % hash_table)
261 type(
hash),
intent(inout) :: hashv
263 hashv % search_index = 1
273 type(
hash),
intent(inout) :: hashv
274 character(*),
intent(out) :: key
275 character(*),
intent(out),
optional :: value
276 logical,
intent(out) :: end
277 integer :: table_size
278 character(STRING) :: value_tmp
281 if (table_size < hashv % search_index)
then 286 key = hashv % hash_table(hashv % search_index) % key
287 value_tmp = hashv % hash_table(hashv % search_index) % value
289 hashv % search_index = hashv % search_index + 1
291 if (
present(
value))
then 305 type(
hash),
intent(in) :: hashv
306 type(
hash) :: hashv_tmp
307 character(len = STRING):: key, value
312 call printf(6,
'#<HASH:: ')
317 call printf(6,
' "%c" -> "%c",', &
318 & c1=trim(key), c2=trim(
value))
325 subroutine dchashget0(hashv, key, value, found)
336 type(
hash),
intent(inout) :: hashv
337 character(*),
intent(in) :: key
338 character(*),
intent(out) :: value
339 logical,
intent(out),
optional :: found
340 character(STRING) :: search_key, search_value
345 call dchashnext(hashv, search_key, search_value, end)
348 if (
present(found)) found = .false.
352 if (trim(search_key) == trim(key))
then 354 if (
present(found)) found = .true.
370 type(
hash),
intent(inout) :: hashv
371 character(*),
intent(in),
optional :: key
373 integer :: table_size, i, j
375 character(STRING) :: search_value
377 if (
present(key))
then 378 call dchashget(hashv, key, search_value, found)
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))
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
394 deallocate(hash_table_tmp)
395 elseif (found .and. table_size == 1)
then 396 deallocate(hashv % hash_table)
399 if (
associated(hashv % hash_table))
deallocate(hashv % hash_table)
integer function dchashnumber0(hashv)
subroutine dchashput0(hashv, key, value)
subroutine dchashget0(hashv, key, value, found)
character(string) function, public joinchar(carray, expr)
subroutine dchashnext0(hashv, key, value, end)
subroutine dchashrewind0(hashv)
subroutine dchashputline0(hashv)
subroutine dchashdelete0(hashv, key)
integer, parameter, public string
文字列を保持する 文字型変数の種別型パラメタ