@@ -51,6 +51,7 @@ program test_chaining_maps
5151 call map % init( fnv_1_hasher, slots_bits= 10 )
5252 call input_random_data( map, test_16, ' FNV-1' , " 16 byte words" )
5353 call test_inquire_data( map, test_16, ' FNV-1' , " 16 byte words" )
54+ call test_get_all_keys( map, test_16, ' FNV-1' , ' 16 byte words' )
5455 call test_get_data( map, test_16, ' FNV-1' , ' 16 byte words' )
5556 call report_rehash_times( map, fnv_1_hasher, ' FNV-1' , ' 16 byte words' )
5657 call report_hash_statistics( map, ' FNV-1' , ' 16 byte words' )
@@ -60,6 +61,7 @@ program test_chaining_maps
6061 call input_random_data( map, test_256, ' FNV-1' , " 256 byte words" )
6162 call test_inquire_data( map, test_256, ' FNV-1' , " 256 byte words" )
6263 call test_get_data( map, test_256, ' FNV-1' , ' 256 byte words' )
64+ call test_get_all_keys( map, test_256, ' FNV-1' , ' 256 byte words' )
6365 call report_rehash_times( map, fnv_1_hasher, ' FNV-1' , ' 256 byte words' )
6466 call report_hash_statistics( map, ' FNV-1' , ' 256 byte words' )
6567 call report_removal_times( map, test_256, ' FNV-1' , ' 256 byte words' )
@@ -68,6 +70,7 @@ program test_chaining_maps
6870 call input_random_data( map, test_16, ' FNV-1A' , " 16 byte words" )
6971 call test_inquire_data( map, test_16, ' FNV-1A' , " 16 byte words" )
7072 call test_get_data( map, test_16, ' FNV-1A' , ' 16 byte words' )
73+ call test_get_all_keys( map, test_16, ' FNV-1A' , ' 16 byte words' )
7174 call report_rehash_times( map, fnv_1a_hasher, ' FNV-1' , ' 16 byte words' )
7275 call report_hash_statistics( map, ' FNV-1A' , ' 16 byte words' )
7376 call report_removal_times( map, test_16, ' FNV-1a' , ' 16 byte words' )
@@ -76,6 +79,7 @@ program test_chaining_maps
7679 call input_random_data( map, test_256, ' FNV-1A' , " 256 byte words" )
7780 call test_inquire_data( map, test_256, ' FNV-1A' , " 256 byte words" )
7881 call test_get_data( map, test_256, ' FNV-1A' , ' 256 byte words' )
82+ call test_get_all_keys( map, test_256, ' FNV-1A' , ' 256 byte words' )
7983 call report_rehash_times( map, fnv_1_hasher, ' FNV-1A' , ' 256 byte words' )
8084 call report_hash_statistics( map, ' FNV-1A' , ' 256 byte words' )
8185 call report_removal_times( map, test_256, ' FNV-1A' , ' 256 byte words' )
@@ -84,6 +88,7 @@ program test_chaining_maps
8488 call input_random_data( map, test_16, ' Seeded_Nmhash32' , " 16 byte words" )
8589 call test_inquire_data( map, test_16, ' Seeded_Nmhash32' , " 16 byte words" )
8690 call test_get_data( map, test_16, ' Seeded_Nmhash32' , ' 16 byte words' )
91+ call test_get_all_keys( map, test_16, ' Seeded_Nmhash32' , ' 16 byte words' )
8792 call report_rehash_times( map, seeded_nmhash32_hasher, ' Seeded_Nmhash32' , &
8893 ' 16 byte words' )
8994 call report_hash_statistics( map, ' Seeded_Nmhash32' , ' 16 byte words' )
@@ -94,6 +99,7 @@ program test_chaining_maps
9499 call input_random_data( map, test_256, ' Seeded_Nmhash32' , " 256 byte words" )
95100 call test_inquire_data( map, test_256, ' Seeded_Nmhash32' , " 256 byte words" )
96101 call test_get_data( map, test_256, ' Seeded_Nmhash32' , ' 256 byte words' )
102+ call test_get_all_keys( map, test_256, ' Seeded_Nmhash32' , ' 256 byte words' )
97103 call report_rehash_times( map, seeded_nmhash32_hasher, ' Seeded_Nmhash32' , &
98104 ' 256 byte words' )
99105 call report_hash_statistics( map, ' Seeded_Nmhash32' , ' 256 byte words' )
@@ -104,6 +110,7 @@ program test_chaining_maps
104110 call input_random_data( map, test_16, ' Seeded_Nmhash32x' , " 16 byte words" )
105111 call test_inquire_data( map, test_16, ' Seeded_Nmhash32x' , " 16 byte words" )
106112 call test_get_data( map, test_16, ' Seeded_Nmhash32x' , ' 16 byte words' )
113+ call test_get_all_keys( map, test_16, ' Seeded_Nmhash32x' , ' 16 byte words' )
107114 call report_rehash_times( map, seeded_nmhash32x_hasher, &
108115 ' Seeded_Nmhash32x' , ' 16 byte words' )
109116 call report_hash_statistics( map, ' Seeded_Nmhash32x' , ' 16 byte words' )
@@ -116,6 +123,7 @@ program test_chaining_maps
116123 call test_inquire_data( map, test_256, ' Seeded_Nmhash32x' , &
117124 " 256 byte words" )
118125 call test_get_data( map, test_256, ' Seeded_Nmhash32x' , ' 256 byte words' )
126+ call test_get_all_keys( map, test_256, ' Seeded_Nmhash32x' , ' 256 byte words' )
119127 call report_rehash_times( map, seeded_nmhash32x_hasher, &
120128 ' Seeded_Nmhash32x' , ' 256 byte words' )
121129 call report_hash_statistics( map, ' Seeded_Nmhash32x' , ' 256 byte words' )
@@ -126,6 +134,7 @@ program test_chaining_maps
126134 call input_random_data( map, test_16, ' Seeded_Water' , " 16 byte words" )
127135 call test_inquire_data( map, test_16, ' Seeded_Water' , " 16 byte words" )
128136 call test_get_data( map, test_16, ' Seeded_Water' , ' 16 byte words' )
137+ call test_get_all_keys( map, test_16, ' Seeded_Water' , ' 16 byte words' )
129138 call report_rehash_times( map, seeded_water_hasher, &
130139 ' Seeded_Water' , ' 16 byte words' )
131140 call report_hash_statistics( map, ' Seeded_Water' , ' 16 byte words' )
@@ -138,6 +147,7 @@ program test_chaining_maps
138147 call test_inquire_data( map, test_256, ' Seeded_Water' , &
139148 " 256 byte words" )
140149 call test_get_data( map, test_256, ' Seeded_Water' , ' 256 byte words' )
150+ call test_get_all_keys( map, test_256, ' Seeded_Water' , ' 256 byte words' )
141151 call report_rehash_times( map, seeded_water_hasher, &
142152 ' Seeded_Water' , ' 256 byte words' )
143153 call report_hash_statistics( map, ' Seeded_Water' , ' 256 byte words' )
@@ -227,6 +237,37 @@ subroutine test_get_data( map, test_block, hash_name, size_name )
227237 end subroutine test_get_data
228238
229239
240+ subroutine test_get_all_keys ( map , test_block , hash_name , size_name )
241+ type (chaining_hashmap_type), intent (inout ) :: map
242+ integer (int_index), intent (in ) :: test_block
243+ character (* ), intent (in ) :: hash_name, size_name
244+ integer :: index2, key_idx
245+ type (key_type) :: key
246+ type (key_type), allocatable :: all_keys(:)
247+ real :: t1, t2, tdiff
248+
249+ call cpu_time(t1)
250+ call map % get_all_keys(all_keys)
251+ call cpu_time(t2)
252+ tdiff = t2- t1
253+
254+ if (size ( all_keys ) /= size ( test_8_bits )/ test_block) &
255+ error stop " Number of keys is different from that of keys in a map."
256+
257+ do index2= 1 , size (test_8_bits), test_block
258+ call set( key, test_8_bits( index2:index2+ test_block-1 ) )
259+
260+ key_idx = ( index2/ test_block ) + 1
261+ if (.not. ( all_keys(key_idx) == key )) &
262+ error stop " Invalid value of a key."
263+ end do
264+
265+ write (lun, ' ("|", a18, " | ", a12, " | ", a15, " | ", f10.5, " |")' ) &
266+ trim (hash_name), ' Get all keys' , size_name, tdiff
267+
268+ end subroutine test_get_all_keys
269+
270+
230271 subroutine report_rehash_times ( map , hasher , hash_name , size_name )
231272 type (chaining_hashmap_type), intent (inout ) :: map
232273 procedure (hasher_fun) :: hasher
0 commit comments