51 type(c_ptr) :: iterator
69 type(sihash_t),
intent(out) :: h
72 subroutine sihash_map_init(map)
bind(c)
78 end subroutine sihash_map_init
82 call sihash_map_init(h%map)
90 type(sihash_t),
intent(inout) :: h
93 subroutine sihash_map_end(map)
bind(c)
99 end subroutine sihash_map_end
102 call sihash_map_end(h%map)
110 type(sihash_t),
intent(inout) :: h
111 character(len=*),
intent(in) :: key
112 integer,
intent(in) :: val
115 subroutine sihash_map_insert(map, key, val)
bind(c)
120 type(c_ptr),
value :: map
121 character(kind=c_char),
intent(in) :: key(*)
122 integer(kind=c_int),
value :: val
123 end subroutine sihash_map_insert
136 type(sihash_t),
intent(in) :: h
137 character(len=*),
intent(in) :: key
138 logical,
optional,
intent(out) :: found
141 subroutine sihash_map_lookup(map, key, ifound, val)
bind(c)
145 type(c_ptr),
value :: map
146 character(kind=c_char),
intent(in) :: key(*)
147 integer(kind=c_int),
intent(out) :: ifound
148 integer(kind=c_int),
intent(out) :: val
149 end subroutine sihash_map_lookup
152 integer :: ifound, val
153 character(kind=c_char) :: key_tmp(
c_str_len(key))
156 call sihash_map_lookup(h%map, key_tmp, ifound, val)
158 found = (ifound == 1)
171 subroutine sihash_iterator_low_start(iterator, end, map)
bind(c)
176 type(c_ptr) :: iterator
178 type(c_ptr),
value :: map
179 end subroutine sihash_iterator_low_start
182 call sihash_iterator_low_start(this%iterator, this%end, h%map)
193 subroutine sihash_iterator_low_has_next(iterator, end, value)
bind(c)
198 type(c_ptr),
value,
intent(in) :: iterator
199 type(c_ptr),
value,
intent(in) :: end
200 integer(kind=c_int),
intent(out) :: value
202 end subroutine sihash_iterator_low_has_next
205 call sihash_iterator_low_has_next(this%iterator, this%end,
value)
216 subroutine sihash_iterator_low_get(iterator, value)
bind(c)
221 type(c_ptr),
intent(in) :: iterator
222 integer(kind=c_int),
intent(out) :: value
224 end subroutine sihash_iterator_low_get
227 call sihash_iterator_low_get(this%iterator,
value)
This module implements a simple hash table for string valued keys and integer values using the C++ ST...
integer function sihash_iterator_get_next(this)
logical function sihash_iterator_has_next(this)
subroutine, public sihash_insert(h, key, val)
Insert a (key, val) pair into the hash table h.
subroutine sihash_iterator_start(this, h)
subroutine, public sihash_init(h)
Initialize a hash table h with size entries. Since we use separate chaining, the number of entries in...
integer function, public sihash_lookup(h, key, found)
Look up a value in the hash table h. If found is present, it indicates if key could be found in the t...
subroutine, public sihash_end(h)
Free a hash table.
integer pure function, public c_str_len(fortran_char)
Convert fortran character length to C character length.
character(kind=c_char, len=1) function, dimension(c_str_len(f_string)), public string_f_to_c(f_string)