Skip to content

Commit 4bb3dac

Browse files
committed
Changed documented structure of other_type
Changed the structure of the `other_type` from a single compone that is a vector of int8s to a single component that is a class(*) allocatable. [ticket: X]
1 parent 0284dee commit 4bb3dac

File tree

1 file changed

+49
-39
lines changed

1 file changed

+49
-39
lines changed

doc/specs/stdlib_hash_maps.md

Lines changed: 49 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ opaque. Their current representations are as follows
118118
119119
type :: other_type
120120
private
121-
integer(int8), allocatable :: value(:)
121+
class(*), allocatable :: value
122122
end type other_type
123123
```
124124

@@ -141,39 +141,40 @@ Procedures to manipulate `key_type` data:
141141

142142
* `equal_keys( key1, key2 )` - compares two keys for equality.
143143

144-
* `get( key, value )` - extracts the contents of key into value, an
145-
`int8` array or character string.
144+
* `get( key, value )` - extracts the contents of `key` into `value`,
145+
an `int8` array or character string.
146146

147-
* `free_key( key )` - frees the memory in key.
147+
* `free_key( key )` - frees the memory in `key`.
148148

149-
* `set( key, value )` - sets the content of key to value.
149+
* `set( key, value )` - sets the content of `key` to `value`.
150150

151151
Procedures to manipulate `other_type` data:
152152

153153
* `copy_other( other_in, other_out )` - Copies the contents of the
154154
other data, `other_in`, to the contents of the other data,
155155
`other_out`.
156156

157-
* `get( other, value )` - extracts the contents of other into value, an
158-
`int8` array or character string.
157+
* `get( other, value )` - extracts the contents of `other` into the
158+
class(*) variable `value`.
159159

160-
* `set( other, value )` - sets to content of other to value.
160+
* `set( other, value )` - sets the content of `other` to the class(*)
161+
variable `value`.
161162

162-
* `free_other( other )` - frees the memory in other.
163+
* `free_other( other )` - frees the memory in `other`.
163164

164165
Procedures to hash keys to 32 bit integers:
165166

166-
* `fnv_1_hasher( key )` - hashes a key using the FNV-1 algorithm.
167+
* `fnv_1_hasher( key )` - hashes a `key` using the FNV-1 algorithm.
167168

168-
* `fnv_1a_hasher( key )` - hashes a key using the FNV-1a algorithm.
169+
* `fnv_1a_hasher( key )` - hashes a `key` using the FNV-1a algorithm.
169170

170-
* `seeded_nmhash32_hasher( key )` - hashes a key using the nmhash32
171+
* `seeded_nmhash32_hasher( key )` - hashes a `key` using the nmhash32
171172
algorithm.
172173

173-
* `seeded_nmhash32x_hasher( key )` - hashes a key using the nmhash32x
174+
* `seeded_nmhash32x_hasher( key )` - hashes a `key` using the nmhash32x
174175
algorithm.
175176

176-
* `seeded_water_hasher( key )` - hashes a key using the waterhash
177+
* `seeded_water_hasher( key )` - hashes a `key` using the waterhash
177178
algorithm.
178179

179180
### Specifications of the `stdlib_hashmap_wrappers` procedures
@@ -186,7 +187,7 @@ Experimental
186187

187188
##### Description
188189

189-
Returns a copy of an input of type `key_type`
190+
Returns a copy of an input of type `key_type`.
190191

191192
##### Syntax
192193

@@ -233,7 +234,7 @@ Experimental
233234

234235
##### Description
235236

236-
Returns a copy of an input of type `other_type`
237+
Returns a copy of an input of type `other_type`.
237238

238239
##### Syntax
239240

@@ -259,18 +260,23 @@ is an `intent(out)` argument.
259260
copy_other, get, other_type, set
260261
use iso_fortran_env, only: int8
261262
implicit none
262-
integer(int8), allocatable :: value1(:), value2(:)
263263
type(other_type) :: other_in, other_out
264264
integer(int_8) :: i
265-
allocate( value1(1:15) )
265+
class(*), allocatable :: dummy
266+
type dummy_type
267+
integer(int8) :: value(15)
268+
end type
269+
type(dummy_type) :: dummy_val
266270
do i=1, 15
267-
value1(i) = i
271+
dummy_val % value1(i) = i
268272
end do
269-
call set( other_in, value1 )
273+
allocate(other_in % value, source=dummy_val)
270274
call copy_other( other_in, other_out )
271-
call get( other_out, value2 )
272-
print *, "other_in == other_out = ", &
273-
all( value1 == value2 )
275+
select type(other_out)
276+
type(dummy_type)
277+
print *, "other_in == other_out = ", &
278+
all( dummy_val % value == other_out % value )
279+
end select
274280
end program demo_copy_other
275281
```
276282

@@ -282,7 +288,7 @@ Experimental
282288

283289
##### Description
284290

285-
Returns `.true.` if two keys are equal, and false otherwise.
291+
Returns `.true.` if two keys are equal, and `.false.` otherwise.
286292

287293
##### Syntax
288294

@@ -548,14 +554,16 @@ is an `intent(out)` argument.
548554
copy_other, free_other, other_type, set
549555
use iso_fortran_env, only: int8
550556
implicit none
551-
integer(int8), allocatable :: value(:)
552-
type(key_type) :: other_in, other_out
557+
type dummy_type
558+
integer(int8) :: value(15)
559+
end type dummy_type
560+
typer(dummy_type) :: dummy_val
561+
type(other_type), allocatable :: other_in, other_out
553562
integer(int_8) :: i
554-
allocate( value(1:15) )
555563
do i=1, 15
556-
value(i) = i
564+
dummy_val % value(i) = i
557565
end do
558-
call set( other_in, value )
566+
allocate(other_in, source=dummy_val)
559567
call copy_other( other_in, other_out )
560568
call free_other( other_out )
561569
end program demo_free_other
@@ -570,8 +578,8 @@ Experimental
570578

571579
##### Description
572580

573-
Extracts the data from a `key_type` or an `other_type` and stores it
574-
in the variable `value`..
581+
Extracts the data from a `key_type` or `other_type` and stores it
582+
in the variable `value`.
575583

576584
##### Syntax
577585

@@ -581,7 +589,6 @@ or
581589

582590
`call [[stdlib_hashmap_wrappers:get]]( other, value )`
583591

584-
585592
##### Class
586593

587594
Subroutine.
@@ -594,9 +601,11 @@ is an `intent(in)` argument.
594601
`other`: shall be a scalar expression of type `other_type`. It
595602
is an `intent(in)` argument.
596603

597-
`value`: shall be an allocatable default character string variable, or
598-
an allocatable vector variable of type integer and kind `int8`. It is
599-
an `intent(out)` argument.
604+
`value`: if the the first argument is of `key_type` `value` shall be
605+
an allocatable default character string variable, or
606+
an allocatable vector variable of type integer and kind `int8`,
607+
otherwise the first argument is of `other_type` and `value` shall be
608+
an allocatable of `class(*)`. It is an `intent(out)` argument.
600609

601610
##### Example
602611

@@ -629,7 +638,7 @@ Experimental
629638
##### Description
630639

631640
Serves as a prototype for hashing functions with a single, `key`,
632-
argument returning an `int32` hash value.
641+
argument of type `key_type` returning an `int32` hash value.
633642

634643
##### Syntax
635644

@@ -894,9 +903,10 @@ is an `intent(out)` argument.
894903
`other`: shall be a scalar variable of type `other_type`. It
895904
is an `intent(out)` argument.
896905

897-
`value`: shall be a default character string expression, or a
898-
vector expression of type integer and kind `int8`. It is an
899-
`intent(in)` argument.
906+
`value`: if the first argument is `key` `vaalue` shall be a default
907+
character string expression, or a vector expression of type integer
908+
and kind `int8`, while for a first argument of type `other` `value`
909+
shall be of type `class(*)`. It is an `intent(in)` argument.
900910

901911
##### Example
902912

0 commit comments

Comments
 (0)