gtool5 Fortran 90/95 Library 1.0.0-rc5
日本語
Loading...
Searching...
No Matches
dc_hash Module Reference

Hash (associative array) module. More...

Data Types

type  hash
interface  dchashput
interface  dchashnumber
interface  dchashputline
interface  dchashrewind
interface  dchashnext
interface  dchashget
interface  dchashdelete
interface  put
interface  number
interface  putline
interface  rewind
interface  next
interface  get
interface  delete

Detailed Description

Hash (associative array) module.

Author
Youhei SASAKI, Yasuhiro MORIKAWA

This module provides hash (associative array) which is familiar in script languages.

Currently, only character type can be given as "value".

Procedures List

Procedure Description
DCHashPut Add key and value to hash
DCHashGet Get associated value from hash with key
DCHashRewind Initialize for searching entire hash
DCHashNext See Rewind
DCHashDelete Delete associated value from hash with key
DCHashNumber Return size of hash
DCHashPutLine Print hash contents to stdout (for debug)

Usage

type(HASH):: hashv
character(len = STRING):: key, value
logical:: end
call dchashput( hashv = hashv, key = 'key1', value = 'val1')
call dchashput( hashv = hashv, key = 'key2', value = 'val2')
call dchashput( hashv = hashv, key = 'key3', value = 'val3')
call dchashget( hashv = hashv, key = 'key1', value = value )
write(*,*) 'key=' // 'key1' // ', value=' // trim(value)
write(*,*) 'number(hashv)=', dchashnumber( hashv )
call dchashdelete( hashv = hashv, key = 'key1')
call dchashrewind( hashv )
do
call dchashnext( hashv = hashv, key = key, value = value, end = end)
if (end) exit
write(*,*) 'key=' // trim(key) // ', value=' // trim(value)
enddo
call dchashdelete( hashv )
Hash (associative array) module.
Definition dc_hash.f90:143
Provides kind type parameter values.
Definition dc_types.f90:55

Output:

key=key1, value=val1
number(hashv)= 3
key=key2, value=val2
key=key3, value=val3