@@ -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
```
@@ -271,26 +271,24 @@ is an `intent(out)` argument.
271
271
272
272
``` fortran
273
273
program demo_copy_other
274
- use stdlib_hashmap_wrappers, only: &
275
- copy_other, get, other_type, set
274
+ use stdlib_hashmap_wrappers, only: copy_other, other_type
276
275
use iso_fortran_env, only: int8
277
276
implicit none
278
277
type(other_type) :: other_in, other_out
279
- integer(int_8) :: i
280
- class(*), allocatable :: dummy
278
+ integer(int8) :: i
281
279
type dummy_type
282
280
integer(int8) :: value(15)
283
281
end type
284
282
type(dummy_type) :: dummy_val
285
- do i= 1, 15
283
+ do i = 1, 15
286
284
dummy_val % value1(i) = i
287
285
end do
288
286
allocate(other_in % value, source=dummy_val)
289
287
call copy_other( other_in, other_out )
290
- select type(other_out)
291
- type(dummy_type)
288
+ select type(out => other_out % value )
289
+ type is (dummy_type)
292
290
print *, "other_in == other_out = ", &
293
- all( dummy_val % value == other_out % value )
291
+ all( dummy_val % value == out % value )
294
292
end select
295
293
end program demo_copy_other
296
294
```
@@ -507,19 +505,19 @@ is an `intent(out)` argument.
507
505
``` fortran
508
506
program demo_free_other
509
507
use stdlib_hashmap_wrappers, only: &
510
- copy_other, free_other, other_type, set
508
+ copy_other, free_other, other_type
511
509
use iso_fortran_env, only: int8
512
510
implicit none
513
511
type dummy_type
514
512
integer(int8) :: value(15)
515
513
end type dummy_type
516
- typer (dummy_type) :: dummy_val
514
+ type (dummy_type) :: dummy_val
517
515
type(other_type), allocatable :: other_in, other_out
518
- integer(int_8 ) :: i
516
+ integer(int8 ) :: i
519
517
do i=1, 15
520
518
dummy_val % value(i) = i
521
519
end do
522
- allocate(other_in, source=dummy_val)
520
+ allocate(other_in % value , source=dummy_val)
523
521
call copy_other( other_in, other_out )
524
522
call free_other( other_out )
525
523
end program demo_free_other
@@ -573,7 +571,7 @@ an allocatable of `class(*)`. It is an `intent(out)` argument.
573
571
implicit none
574
572
integer(int8), allocatable :: value(:), result(:)
575
573
type(key_type) :: key
576
- integer(int_8 ) :: i
574
+ integer(int8 ) :: i
577
575
allocate( value(1:15) )
578
576
do i=1, 15
579
577
value(i) = i
@@ -585,7 +583,7 @@ an allocatable of `class(*)`. It is an `intent(out)` argument.
585
583
```
586
584
587
585
588
- #### ` hasher_fun ` - serves aa a function prototype.
586
+ #### ` hasher_fun ` - serves as a function prototype.
589
587
590
588
##### Status
591
589
@@ -933,7 +931,7 @@ value to an `int8` vector.
933
931
implicit none
934
932
integer(int8), allocatable :: value(:), result(:)
935
933
type(key_type) :: key
936
- integer(int_8 ) :: i
934
+ integer(int8 ) :: i
937
935
allocate( value(1:15) )
938
936
do i=1, 15
939
937
value(i) = i
@@ -1392,7 +1390,7 @@ The result will be the number of procedure calls on the hash map.
1392
1390
use stdlib_hashmap_wrappers, only: fnv_1_hasher
1393
1391
implicit none
1394
1392
type(chaining_hashmap_type) :: map
1395
- type (int_calls) :: initial_calls
1393
+ integer (int_calls) :: initial_calls
1396
1394
call map % init( fnv_1_hasher )
1397
1395
initial_calls = map % calls()
1398
1396
print *, "INITIAL_CALLS = ", initial_calls
@@ -1518,9 +1516,9 @@ undefined.
1518
1516
end if
1519
1517
call get( other, data )
1520
1518
select type( data )
1521
- type (dummy_type)
1519
+ type is (dummy_type)
1522
1520
print *, 'Other data % value = ', data % value
1523
- type default
1521
+ class default
1524
1522
print *, 'Invalid data type in other'
1525
1523
end select
1526
1524
end program demo_get_other_data
@@ -1565,7 +1563,7 @@ Subroutine
1565
1563
error code.
1566
1564
1567
1565
* If ` slots_bits ` is absent then the effective value for ` slots_bits `
1568
- is ` default_slots_bits ` .
1566
+ is ` default_bits ` .
1569
1567
1570
1568
` status ` (optional): shall be a scalar integer variable of kind
1571
1569
` int32 ` . It is an ` intent(out) ` argument. On return if present it
@@ -1587,11 +1585,11 @@ has the value `alloc_fault`.
1587
1585
1588
1586
``` fortran
1589
1587
program demo_init
1590
- use stdlib_hashmaps, only: chaining_map_type
1588
+ use stdlib_hashmaps, only: chaining_hashmap_type
1591
1589
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 )
1590
+ implicit none
1591
+ type(chaining_hashmap_type ) :: map
1592
+ call map % init( fnv_1_hasher , slots_bits=10 )
1595
1593
end program demo_init
1596
1594
```
1597
1595
@@ -1748,7 +1746,7 @@ is ignored.
1748
1746
program demo_map_entry
1749
1747
use, intrinsic:: iso_fortran_env, only: int8
1750
1748
use stdlib_hashmaps, only: chaining_hashmap_type
1751
- use stdlib_hashmap_wrappers, only: fnv_1_hasher, key_type, other_type
1749
+ use stdlib_hashmap_wrappers, only: fnv_1_hasher, key_type, other_type, set
1752
1750
type(chaining_hashmap_type) :: map
1753
1751
type(key_type) :: key
1754
1752
logical :: conflict
@@ -1806,7 +1804,7 @@ rehashing.
1806
1804
type(chaining_hashmap_type) :: map
1807
1805
real :: nprobes
1808
1806
call map % init( fnv_1_hasher )
1809
- nprobes = map % probes ()
1807
+ nprobes = map % map_probes ()
1810
1808
print *, "Initial probes = ", nprobes
1811
1809
end program demo_probes
1812
1810
```
@@ -1855,7 +1853,7 @@ The result is the number of slots in `map`.
1855
1853
call map % init( fnv_1_hasher )
1856
1854
initial_slots = map % num_slots ()
1857
1855
print *, "Initial slots = ", initial_slots
1858
- end program num_slots
1856
+ end program demo_num_slots
1859
1857
```
1860
1858
1861
1859
@@ -1891,10 +1889,12 @@ It is the hash method to be used by `map`.
1891
1889
1892
1890
``` fortran
1893
1891
program demo_rehash
1892
+ use stdlib_kinds, only: int8
1894
1893
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
1894
+ use stdlib_hashmap_wrappers, only: fnv_1_hasher, fnv_1a_hasher,&
1895
+ key_type, other_type, set
1896
+ implicit none
1897
+ type(open_hashmap_type) :: map
1898
1898
type(key_type) :: key
1899
1899
type(other_type) :: other
1900
1900
class(*), allocatable :: dummy
@@ -2009,20 +2009,23 @@ not exist and nothing was done.
2009
2009
2010
2010
``` fortran
2011
2011
program demo_set_other_data
2012
+ use stdlib_kinds, only: int8
2012
2013
use stdlib_hashmaps, only: open_hashmap_type
2013
2014
use stdlib_hashmap_wrappers, only: fnv_1_hasher, &
2014
2015
fnv_1a_hasher, key_type, other_type, set
2016
+ implicit none
2017
+ logical :: exists
2015
2018
type(open_hashmap_type) :: map
2016
2019
type(key_type) :: key
2017
2020
type(other_type) :: other
2018
2021
class(*), allocatable :: dummy
2019
2022
call map % init( fnv_1_hasher, slots_bits=10 )
2020
- allocate( dummy, source='A value` )
2023
+ allocate( dummy, source='A value' )
2021
2024
call set( key, [ 5_int8, 7_int8, 4_int8, 13_int8 ] )
2022
2025
call set( other, dummy )
2023
2026
call map % map_entry( key, other )
2024
2027
deallocate( dummy )
2025
- allocate( dummy, source='Another value` )
2028
+ allocate( dummy, source='Another value' )
2026
2029
call set( other, dummy )
2027
2030
call map % set_other_data( key, other, exists )
2028
2031
print *, 'The entry to have its other data replaced exists = ', exists
0 commit comments