@@ -5,7 +5,7 @@ program example_get_other_data
55 implicit none
66 logical :: conflict
77 type (key_type) :: key
8- type (other_type) :: other
8+
99 type (chaining_hashmap_type) :: map
1010 type dummy_type
1111 integer :: value(4 )
@@ -21,17 +21,18 @@ program example_get_other_data
2121 ! Hashmap functions are setup to store scalar value types (other). Use a dervied
2222 ! type wrapper to store arrays.
2323 dummy% value = [4 , 3 , 2 , 1 ]
24- call set(other, dummy)
2524
2625 ! Explicitly set key type using set function
2726 call set(key, [0 , 1 ])
28- call map% map_entry(key, other , conflict)
27+ call map% map_entry(key, dummy , conflict)
2928 if (.not. conflict) then
30- call map% get_other_data(key, other )
29+ call map% get_other_data(key, data )
3130 else
3231 error stop ' Key is already present in the map.'
3332 end if
34- call get(other, data )
33+
34+ ! Get_other_data returns data as an unlimited polymorphic scalar.
35+ ! To use this type in other operations, there must be a select type operation.
3536 select type (data )
3637 type is (dummy_type)
3738 print * , ' Other data % value = ' , data % value
@@ -41,29 +42,29 @@ program example_get_other_data
4142
4243! Also can use map_entry and get_other_data generic key interfaces.
4344! This is an exmple with integer arrays.
44- call map% map_entry( [2 ,3 ], other , conflict)
45+ call map% map_entry( [2 ,3 ], dummy , conflict)
4546 if (.not. conflict) then
46- call map% get_other_data( [2 ,3 ], other )
47+ call map% get_other_data( [2 ,3 ], data )
4748 else
4849 error stop ' Key is already present in the map.'
4950 end if
50- call get(other, data )
51+
5152 select type (data )
5253 type is (dummy_type)
5354 print * , ' Other data % value = ' , data % value
5455 class default
5556 print * , ' Invalid data type in other'
5657 end select
5758
58- ! Integer scalars need to be passed as an array.
59+ ! Integer scalar keys need to be passed as an array.
5960 int_scalar = 2
60- call map% map_entry( [int_scalar], other , conflict)
61+ call map% map_entry( [int_scalar], dummy , conflict)
6162 if (.not. conflict) then
62- call map% get_other_data( [int_scalar], other )
63+ call map% get_other_data( [int_scalar], data )
6364 else
6465 error stop ' Key is already present in the map.'
6566 end if
66- call get(other, data )
67+
6768 select type (data )
6869 type is (dummy_type)
6970 print * , ' Other data % value = ' , data % value
@@ -72,13 +73,13 @@ program example_get_other_data
7273 end select
7374
7475 ! Example using character type key interface
75- call map% map_entry( ' key_string' , other , conflict)
76+ call map% map_entry( ' key_string' , dummy , conflict)
7677 if (.not. conflict) then
77- call map% get_other_data( ' key_string' , other )
78+ call map% get_other_data( ' key_string' , data )
7879 else
7980 error stop ' Key is already present in the map.'
8081 end if
81- call get(other, data )
82+
8283 select type (data )
8384 type is (dummy_type)
8485 print * , ' Other data % value = ' , data % value
@@ -88,13 +89,13 @@ program example_get_other_data
8889
8990! Transfer to int8 arrays to generate key for unsupported types.
9091 key_array = transfer ( [0_int64 , 1_int64 ], [0_int8 ] )
91- call map% map_entry( key_array, other , conflict)
92+ call map% map_entry( key_array, dummy , conflict)
9293 if (.not. conflict) then
93- call map% get_other_data( key_array, other )
94+ call map% get_other_data( key_array, data )
9495 else
9596 error stop ' Key is already present in the map.'
9697 end if
97- call get(other, data )
98+
9899 select type (data )
99100 type is (dummy_type)
100101 print * , ' Other data % value = ' , data % value
0 commit comments