You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use stdlib_hashmaps, only: chaining_hashmap_type, open_hashmap_type
3
3
use stdlib_hashmap_wrappers, only: fnv_1_hasher
4
4
implicit none
5
5
type(chaining_hashmap_type) :: map
6
-
call map%init(fnv_1_hasher, slots_bits=10)
6
+
logical:: present
7
+
8
+
9
+
!If default values are used, then init can be typically be skipped as the first map_entry call will initialize the map using default values.
10
+
call map%map_entry('key', 'value')
11
+
call map%key_test('key', present)
12
+
print*, "Key exists without explicit init call = ", present
13
+
14
+
! Init can be called to clear all items in a map.
15
+
call map%init()
16
+
call map%key_test('key', present)
17
+
print*, "Key exists after re-initalization = ", present
18
+
19
+
! User can optional specify hasher type and slots_bits instead of using default values.
20
+
! Number of slots in the hashmap will initially equal 2**slots_bits.
21
+
! The hashmap will automatically re-size as needed; however for better performance, a rule of thumb is to size so that number of slots is ~2X expected number of entries.
22
+
! In this example with slots_bits=10, there will initially be 1024 slots in the map.
0 commit comments