Skip to content

Commit f44133b

Browse files
authored
Merge pull request #778 from chuckyvt/hashmap_int32_key
Update to include int32 hashmap keytype
2 parents 19f84ce + f35386f commit f44133b

File tree

3 files changed

+166
-72
lines changed

3 files changed

+166
-72
lines changed

Diff for: doc/specs/stdlib_hashmaps.md

+12-9
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,13 @@ Procedures to manipulate `key_type` data:
157157
`key_in`, to contents of the key, `key_out`.
158158

159159
* `get( key, value )` - extracts the contents of `key` into `value`,
160-
an `int8` array or character string.
160+
an `int8` array, 'int32' array, or character string.
161161

162162
* `free_key( key )` - frees the memory in `key`.
163163

164-
* `set( key, value )` - sets the content of `key` to `value`.
164+
* `set( key, value )` - sets the content of `key` to `value`.
165+
Supported key types are `int8` array, `int32` array, and character
166+
string.
165167

166168
Procedures to manipulate `other_type` data:
167169

@@ -474,9 +476,9 @@ is an `intent(in)` argument.
474476

475477
`value`: if the the first argument is of `key_type` `value` shall be
476478
an allocatable default character string variable, or
477-
an allocatable vector variable of type integer and kind `int8`,
478-
otherwise the first argument is of `other_type` and `value` shall be
479-
an allocatable of `class(*)`. It is an `intent(out)` argument.
479+
an allocatable vector variable of type integer and kind `int8` or
480+
`int32`, otherwise the first argument is of `other_type` and `value`
481+
shall be an allocatable of `class(*)`. It is an `intent(out)` argument.
480482

481483
##### Example
482484

@@ -751,13 +753,14 @@ is an `intent(out)` argument.
751753

752754
`value`: if the first argument is `key` `value` shall be a default
753755
character string scalar expression, or a vector expression of type integer
754-
and kind `int8`, while for a first argument of type `other` `value`
755-
shall be of type `class(*)`. It is an `intent(in)` argument.
756+
and kind `int8` or `int32`, while for a first argument of type
757+
`other` `value` shall be of type `class(*)`. It is an `intent(in)`
758+
argument.
756759

757760
##### Note
758761

759-
Values of types other than a scalar default character or an
760-
`int8` vector can be used as the basis of a `key` by transferring the
762+
Values of types other than a scalar default character or and
763+
`int8` or `int32` vector can be used as the basis of a `key` by transferring the
761764
value to an `int8` vector.
762765

763766
##### Example

Diff for: src/stdlib_hashmap_wrappers.f90

+32
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ end function hasher_fun
8888

8989
module procedure get_char_key, &
9090
get_int8_key, &
91+
get_int32_key, &
9192
get_other
9293

9394
end interface get
@@ -101,6 +102,7 @@ end function hasher_fun
101102

102103
module procedure set_char_key, &
103104
set_int8_key, &
105+
set_int32_key, &
104106
set_other
105107

106108
end interface set
@@ -277,6 +279,21 @@ subroutine get_int8_key( key, value )
277279
end subroutine get_int8_key
278280

279281

282+
pure subroutine get_int32_key( key, value )
283+
!! Version: Experimental
284+
!!
285+
!! Gets the contents of the key as an INTEGER(INT32) vector
286+
!! Arguments:
287+
!! key - the input key
288+
!! value - the contents of key mapped to an INTEGER(INT32) vector
289+
type(key_type), intent(in) :: key
290+
integer(int32), allocatable, intent(out) :: value(:)
291+
292+
value = transfer( key % value, value )
293+
294+
end subroutine get_int32_key
295+
296+
280297
subroutine set_char_key( key, value )
281298
!! Version: Experimental
282299
!!
@@ -323,6 +340,21 @@ subroutine set_int8_key( key, value )
323340
end subroutine set_int8_key
324341

325342

343+
pure subroutine set_int32_key( key, value )
344+
!! Version: Experimental
345+
!!
346+
!! Sets the contents of the key from an INTEGER(INT32) vector
347+
!! Arguments:
348+
!! key - the output key
349+
!! value - the input INTEGER(INT32) vector
350+
type(key_type), intent(out) :: key
351+
integer(int32), intent(in) :: value(:)
352+
353+
key % value = transfer(value, key % value)
354+
355+
end subroutine set_int32_key
356+
357+
326358
pure function fnv_1_hasher( key )
327359
!! Version: Experimental
328360
!!

0 commit comments

Comments
 (0)