@@ -21,7 +21,7 @@ This document discusses the hash maps in the Fortran Standard Library.
21
21
22
22
The Fortran Standard Library is distributed under the MIT License.
23
23
However components of the library should be evaluated as to whether
24
- they are compatible with the MTI License.
24
+ they are compatible with the MIT License.
25
25
The current hash maps were inspired by an
26
26
[ implementation] ( http://chasewoerner.org/src/hasht/ ) of David
27
27
Chase. While the code has been greatly modified from his
@@ -229,14 +229,14 @@ is an `intent(out)` argument.
229
229
``` fortran
230
230
program demo_copy_key
231
231
use stdlib_hashmap_wrappers, only: &
232
- copy_key, operator(==), key_type
232
+ copy_key, operator(==), key_type, set
233
233
use iso_fortran_env, only: int8
234
234
implicit none
235
235
integer(int8) :: i, value(15)
236
236
type(key_type) :: old_key, new_key
237
237
value = [(i, i = 1, 15)]
238
- call set( key_out , value )
239
- call copy_key( key_out , new_key )
238
+ call set( old_key , value )
239
+ call copy_key( old_key , new_key )
240
240
print *, "old_key == new_key = ", old_key == new_key
241
241
end program demo_copy_key
242
242
```
@@ -276,7 +276,7 @@ is an `intent(out)` argument.
276
276
use iso_fortran_env, only: int8
277
277
implicit none
278
278
type(other_type) :: other_in, other_out
279
- integer(int_8 ) :: i
279
+ integer(int8 ) :: i
280
280
class(*), allocatable :: dummy
281
281
type dummy_type
282
282
integer(int8) :: value(15)
@@ -287,8 +287,8 @@ is an `intent(out)` argument.
287
287
end do
288
288
allocate(other_in % value, source=dummy_val)
289
289
call copy_other( other_in, other_out )
290
- select type(other_out)
291
- type (dummy_type)
290
+ select type(other_out) !there is an issue here, please check.
291
+ typeis (dummy_type)
292
292
print *, "other_in == other_out = ", &
293
293
all( dummy_val % value == other_out % value )
294
294
end select
@@ -507,19 +507,19 @@ is an `intent(out)` argument.
507
507
``` fortran
508
508
program demo_free_other
509
509
use stdlib_hashmap_wrappers, only: &
510
- copy_other, free_other, other_type, set
510
+ copy_other, free_other, other_type
511
511
use iso_fortran_env, only: int8
512
512
implicit none
513
513
type dummy_type
514
514
integer(int8) :: value(15)
515
515
end type dummy_type
516
- typer (dummy_type) :: dummy_val
516
+ type (dummy_type) :: dummy_val
517
517
type(other_type), allocatable :: other_in, other_out
518
- integer(int_8 ) :: i
518
+ integer(int8 ) :: i
519
519
do i=1, 15
520
520
dummy_val % value(i) = i
521
521
end do
522
- allocate(other_in, source=dummy_val)
522
+ allocate(other_in % value , source=dummy_val)
523
523
call copy_other( other_in, other_out )
524
524
call free_other( other_out )
525
525
end program demo_free_other
@@ -573,7 +573,7 @@ an allocatable of `class(*)`. It is an `intent(out)` argument.
573
573
implicit none
574
574
integer(int8), allocatable :: value(:), result(:)
575
575
type(key_type) :: key
576
- integer(int_8 ) :: i
576
+ integer(int8 ) :: i
577
577
allocate( value(1:15) )
578
578
do i=1, 15
579
579
value(i) = i
@@ -585,7 +585,7 @@ an allocatable of `class(*)`. It is an `intent(out)` argument.
585
585
```
586
586
587
587
588
- #### ` hasher_fun ` - serves aa a function prototype.
588
+ #### ` hasher_fun ` - serves as a function prototype.
589
589
590
590
##### Status
591
591
@@ -933,7 +933,7 @@ value to an `int8` vector.
933
933
implicit none
934
934
integer(int8), allocatable :: value(:), result(:)
935
935
type(key_type) :: key
936
- integer(int_8 ) :: i
936
+ integer(int8 ) :: i
937
937
allocate( value(1:15) )
938
938
do i=1, 15
939
939
value(i) = i
@@ -1392,7 +1392,7 @@ The result will be the number of procedure calls on the hash map.
1392
1392
use stdlib_hashmap_wrappers, only: fnv_1_hasher
1393
1393
implicit none
1394
1394
type(chaining_hashmap_type) :: map
1395
- type (int_calls) :: initial_calls
1395
+ integer (int_calls) :: initial_calls
1396
1396
call map % init( fnv_1_hasher )
1397
1397
initial_calls = map % calls()
1398
1398
print *, "INITIAL_CALLS = ", initial_calls
@@ -1518,9 +1518,9 @@ undefined.
1518
1518
end if
1519
1519
call get( other, data )
1520
1520
select type( data )
1521
- type (dummy_type)
1521
+ typeis (dummy_type)
1522
1522
print *, 'Other data % value = ', data % value
1523
- type default
1523
+ class default
1524
1524
print *, 'Invalid data type in other'
1525
1525
end select
1526
1526
end program demo_get_other_data
@@ -1587,11 +1587,11 @@ has the value `alloc_fault`.
1587
1587
1588
1588
``` fortran
1589
1589
program demo_init
1590
- use stdlib_hashmaps, only: chaining_map_type
1590
+ use stdlib_hashmaps, only: chaining_hashmap_type
1591
1591
use stdlib_hashmap_wrappers, only: fnv_1_hasher
1592
- type(fnv_1a_type) :: fnv_1
1593
- type(chaining_map_type ) :: map
1594
- call map % init( fnv_1a , slots_bits=10 )
1592
+ implicit none
1593
+ type(chaining_hashmap_type ) :: map
1594
+ call map % init( fnv_1_hasher , slots_bits=10 )
1595
1595
end program demo_init
1596
1596
```
1597
1597
@@ -1748,7 +1748,7 @@ is ignored.
1748
1748
program demo_map_entry
1749
1749
use, intrinsic:: iso_fortran_env, only: int8
1750
1750
use stdlib_hashmaps, only: chaining_hashmap_type
1751
- use stdlib_hashmap_wrappers, only: fnv_1_hasher, key_type, other_type
1751
+ use stdlib_hashmap_wrappers, only: fnv_1_hasher, key_type, other_type, set
1752
1752
type(chaining_hashmap_type) :: map
1753
1753
type(key_type) :: key
1754
1754
logical :: conflict
@@ -1806,7 +1806,7 @@ rehashing.
1806
1806
type(chaining_hashmap_type) :: map
1807
1807
real :: nprobes
1808
1808
call map % init( fnv_1_hasher )
1809
- nprobes = map % probes ()
1809
+ nprobes = map % map_probes ()
1810
1810
print *, "Initial probes = ", nprobes
1811
1811
end program demo_probes
1812
1812
```
@@ -1855,7 +1855,7 @@ The result is the number of slots in `map`.
1855
1855
call map % init( fnv_1_hasher )
1856
1856
initial_slots = map % num_slots ()
1857
1857
print *, "Initial slots = ", initial_slots
1858
- end program num_slots
1858
+ end program demo_num_slots
1859
1859
```
1860
1860
1861
1861
@@ -1891,10 +1891,12 @@ It is the hash method to be used by `map`.
1891
1891
1892
1892
``` fortran
1893
1893
program demo_rehash
1894
+ use stdlib_kinds, only: int8
1894
1895
use stdlib_hashmaps, only: open_hashmap_type
1895
- use stdlib_hasmap_wrappers, only: fnv_1_hasher, fnv_1a_hasher,&
1896
- key_type, other_type
1897
- type(openn_hashmap_type) :: map
1896
+ use stdlib_hashmap_wrappers, only: fnv_1_hasher, fnv_1a_hasher,&
1897
+ key_type, other_type, set
1898
+ implicit none
1899
+ type(open_hashmap_type) :: map
1898
1900
type(key_type) :: key
1899
1901
type(other_type) :: other
1900
1902
class(*), allocatable :: dummy
@@ -2009,20 +2011,23 @@ not exist and nothing was done.
2009
2011
2010
2012
``` fortran
2011
2013
program demo_set_other_data
2014
+ use stdlib_kinds, only: int8
2012
2015
use stdlib_hashmaps, only: open_hashmap_type
2013
2016
use stdlib_hashmap_wrappers, only: fnv_1_hasher, &
2014
2017
fnv_1a_hasher, key_type, other_type, set
2018
+ implicit none
2019
+ logical :: exists
2015
2020
type(open_hashmap_type) :: map
2016
2021
type(key_type) :: key
2017
2022
type(other_type) :: other
2018
2023
class(*), allocatable :: dummy
2019
2024
call map % init( fnv_1_hasher, slots_bits=10 )
2020
- allocate( dummy, source='A value` )
2025
+ allocate( dummy, source='A value' )
2021
2026
call set( key, [ 5_int8, 7_int8, 4_int8, 13_int8 ] )
2022
2027
call set( other, dummy )
2023
2028
call map % map_entry( key, other )
2024
2029
deallocate( dummy )
2025
- allocate( dummy, source='Another value` )
2030
+ allocate( dummy, source='Another value' )
2026
2031
call set( other, dummy )
2027
2032
call map % set_other_data( key, other, exists )
2028
2033
print *, 'The entry to have its other data replaced exists = ', exists
0 commit comments