-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathstdlib_hashmap_open.f90.html
1116 lines (1075 loc) · 231 KB
/
stdlib_hashmap_open.f90.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!-- -*- mode: jinja2 -*- -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="A community driven standard library for (modern) Fortran">
<meta name="author" content="fortran-lang/stdlib contributors" >
<link rel="icon" href="../favicon.png">
<title>stdlib_hashmap_open.f90 – Fortran-lang/stdlib</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<link href="../css/pygments.css" rel="stylesheet">
<link href="../css/font-awesome.min.css" rel="stylesheet">
<link href="../css/local.css" rel="stylesheet">
<link href="../tipuesearch/tipuesearch.css" rel="stylesheet">
<script src="https://code.jquery.com/jquery-3.7.1.min.js" integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo=" crossorigin="anonymous"></script>
<script src="../js/svg-pan-zoom.min.js"></script>
</head>
<body>
<!-- Fixed navbar -->
<div class="container-fluid mb-sm-4 mb-xl-2">
<nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top">
<div class="container">
<a class="navbar-brand" href="../index.html">Fortran-lang/stdlib </a>
<button type="button" class="navbar-toggler" data-bs-toggle="collapse" data-bs-target="#navbar"
aria-expanded="false" aria-controls="navbar" aria-label="Toggle navigation">
<span class="navbar-toggler-icon">
</button>
<div id="navbar" class="navbar-collapse collapse">
<ul class="navbar-nav">
<li class="nav-item"><a class="nav-link" href="../page/index.html">Contributing and specs</a></li>
<li class="nav-item">
<a class="nav-link" href="../lists/files.html">Source Files</a>
</li>
<li class="nav-item">
<a class="nav-link" href="../lists/modules.html">Modules</a>
</li>
<li class="nav-item">
<a class="nav-link" href="../lists/procedures.html">Procedures</a>
</li>
<li class="nav-item">
<a class="nav-link" href="../lists/absint.html">Abstract Interfaces</a>
</li>
<li class="nav-item">
<a class="nav-link" href="../lists/types.html">Derived Types</a>
</li>
</ul>
<div class="d-flex align-items-end flex-grow-1">
<form action="../search.html" role="search" class="ms-auto">
<input type="text" class="form-control" aria-label="Search" placeholder="Search" name="q" id="tipue_search_input" autocomplete="off" required>
</form>
</div>
</div><!--/.nav-collapse -->
</div>
</nav>
</div>
<div class="container">
<div class="row">
<h1>stdlib_hashmap_open.f90
<small>Source File</small>
</h1>
<div class="container p-2 mb-4 bg-light border rounded-3">
<div class="row align-items-center justify-content-between" id="info-bar">
<div class="col">
<ul class="list-inline" style="margin-bottom:0px;display:inline">
<li class="list-inline-item" id="meta-license"><i class="fa fa-legal"></i> <a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-sa/4.0/80x15.png" /></a></li>
<li class="list-inline-item" id="statements"><i class="fa fa-list-ol"></i>
<a data-bs-toggle="tooltip"
data-bs-placement="bottom" data-html="true"
title=" 0.2% of total for source files.">533 statements</a>
</li>
<li class="list-inline-item" id="source-file">
<i class="fa fa-code"></i>
<a href="../src/stdlib_hashmap_open.f90"> Source File</a>
</li>
</ul>
</div>
<div class="col">
<nav aria-label="breadcrumb">
<ol class="breadcrumb justify-content-end mb-0">
<li class="breadcrumb-item active" aria-current="page">stdlib_hashmap_open.f90</li>
</ol>
</nav>
</div>
</div>
</div>
<script>
$(function () {
$('[data-bs-toggle="tooltip"]').tooltip()
})
</script>
</div>
<div class="row">
<div class="col-md-3 hidden-xs hidden-sm visible-md visible-lg">
<div id="sidebar">
<h3>Contents</h3>
<div class="card mb-4">
<a data-bs-toggle="collapse" href="#submods-0"
aria-expanded="false" aria-controls="submods-0">
<h4 class="card-header bg-primary text-white">Submodules</h4>
</a>
<div id="submods-0" class="collapse">
<div class="list-group list-group-flush">
<a class="list-group-item" href="../module/stdlib_hashmap_open.html">stdlib_hashmap_open</a>
</div>
</div>
</div>
<div class="card card-primary">
<div class="card-header text-left"><h3 class="card-title">Source Code</h3></div>
<div class="list-group">
<a class="list-group-item" href="../sourcefile/stdlib_hashmap_open.f90.html#src">stdlib_hashmap_open.f90</a>
</div>
</div>
</div>
</div>
<div class="col-md-9" id='text'>
<p>The module, STDLIB_HASHMAP_OPEN implements a simple open addressing hash
map using linear addressing. The implementation is loosely based on a
C implementation by David Chase, http://chasewoerner.org/src/hasht/, for
which he has given permission to use in the Fortran Standard Library.</p>
<br>
<br>
<section>
<h2><span class="anchor" id="src"></span>Source Code</h2>
<div class="hl codehilite"><pre><span></span><a id="ln-1" name="ln-1" href="#ln-1"></a><span class="c">!! The module, STDLIB_HASHMAP_OPEN implements a simple open addressing hash</span>
<a id="ln-2" name="ln-2" href="#ln-2"></a><span class="c">!! map using linear addressing. The implementation is loosely based on a</span>
<a id="ln-3" name="ln-3" href="#ln-3"></a><span class="c">!! C implementation by David Chase, http://chasewoerner.org/src/hasht/, for</span>
<a id="ln-4" name="ln-4" href="#ln-4"></a><span class="c">!! which he has given permission to use in the Fortran Standard Library.</span>
<a id="ln-5" name="ln-5" href="#ln-5"></a>
<a id="ln-6" name="ln-6" href="#ln-6"></a><span class="c">! Note an error in the code caused attempts to deallocate already deallocated</span>
<a id="ln-7" name="ln-7" href="#ln-7"></a><span class="c">! entries. This did not cause stat to be non-zero, but did cause system errors,</span>
<a id="ln-8" name="ln-8" href="#ln-8"></a><span class="c">! on my Mac. I therefore decided to remove all deallocation error reporting.</span>
<a id="ln-9" name="ln-9" href="#ln-9"></a>
<a id="ln-10" name="ln-10" href="#ln-10"></a><span class="k">submodule</span><span class="p">(</span><span class="n">stdlib_hashmaps</span><span class="p">)</span><span class="w"> </span><span class="n">stdlib_hashmap_open</span>
<a id="ln-11" name="ln-11" href="#ln-11"></a>
<a id="ln-12" name="ln-12" href="#ln-12"></a><span class="w"> </span><span class="k">use</span><span class="p">,</span><span class="w"> </span><span class="k">intrinsic</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">iso_fortran_env</span><span class="p">,</span><span class="w"> </span><span class="k">only</span><span class="p">:</span><span class="w"> </span><span class="p">&</span>
<a id="ln-13" name="ln-13" href="#ln-13"></a><span class="w"> </span><span class="n">character_storage_size</span><span class="p">,</span><span class="w"> </span><span class="p">&</span>
<a id="ln-14" name="ln-14" href="#ln-14"></a><span class="w"> </span><span class="n">error_unit</span>
<a id="ln-15" name="ln-15" href="#ln-15"></a>
<a id="ln-16" name="ln-16" href="#ln-16"></a><span class="w"> </span><span class="k">use </span><span class="n">stdlib_hashmap_wrappers</span>
<a id="ln-17" name="ln-17" href="#ln-17"></a>
<a id="ln-18" name="ln-18" href="#ln-18"></a><span class="w"> </span><span class="k">implicit none</span>
<a id="ln-19" name="ln-19" href="#ln-19"></a>
<a id="ln-20" name="ln-20" href="#ln-20"></a><span class="c">! Error messages</span>
<a id="ln-21" name="ln-21" href="#ln-21"></a><span class="w"> </span><span class="kt">character</span><span class="p">(</span><span class="nb">len</span><span class="o">=*</span><span class="p">),</span><span class="w"> </span><span class="k">parameter</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="p">&</span>
<a id="ln-22" name="ln-22" href="#ln-22"></a><span class="w"> </span><span class="n">alloc_inv_fault</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">"OPEN_HASHMAP_TYPE % INVERSE allocation fault."</span><span class="p">,</span><span class="w"> </span><span class="p">&</span>
<a id="ln-23" name="ln-23" href="#ln-23"></a><span class="w"> </span><span class="n">alloc_key_fault</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">"KEY allocation fault."</span><span class="p">,</span><span class="w"> </span><span class="p">&</span>
<a id="ln-24" name="ln-24" href="#ln-24"></a><span class="w"> </span><span class="n">alloc_slots_fault</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">"OPEN_HASHMAP_TYPE % SLOTS allocation fault."</span><span class="p">,</span><span class="w"> </span><span class="p">&</span>
<a id="ln-25" name="ln-25" href="#ln-25"></a><span class="w"> </span><span class="n">conflicting_key</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">"KEY already exists in MAP."</span><span class="p">,</span><span class="w"> </span><span class="p">&</span>
<a id="ln-26" name="ln-26" href="#ln-26"></a><span class="w"> </span><span class="n">expand_slots_fail</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">"OPEN_HASHMAP_TYPE % SLOTS allocation > "</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="p">&</span>
<a id="ln-27" name="ln-27" href="#ln-27"></a><span class="w"> </span><span class="s2">"MAX_BITS."</span><span class="p">,</span><span class="w"> </span><span class="p">&</span>
<a id="ln-28" name="ln-28" href="#ln-28"></a><span class="w"> </span><span class="n">init_slots_pow_fail</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">"SLOTS_BITS is not between DEFAULT_BITS "</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="p">&</span>
<a id="ln-29" name="ln-29" href="#ln-29"></a><span class="w"> </span><span class="s2">"and MAX_BITS."</span><span class="p">,</span><span class="w"> </span><span class="p">&</span>
<a id="ln-30" name="ln-30" href="#ln-30"></a><span class="w"> </span><span class="n">invalid_inmap</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">"INMAP was not a valid INVERSE index."</span><span class="p">,</span><span class="w"> </span><span class="p">&</span>
<a id="ln-31" name="ln-31" href="#ln-31"></a><span class="w"> </span><span class="n">map_consist_fault</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">"The hash map found an inconsistency."</span>
<a id="ln-32" name="ln-32" href="#ln-32"></a>
<a id="ln-33" name="ln-33" href="#ln-33"></a><span class="w"> </span><span class="kt">character</span><span class="p">(</span><span class="o">*</span><span class="p">),</span><span class="w"> </span><span class="k">parameter</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">submodule_name</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'STDLIB_HASHMAP_OPEN'</span>
<a id="ln-34" name="ln-34" href="#ln-34"></a>
<a id="ln-35" name="ln-35" href="#ln-35"></a>
<a id="ln-36" name="ln-36" href="#ln-36"></a><span class="w"> </span><span class="k">interface </span><span class="n">expand_slots</span>
<a id="ln-37" name="ln-37" href="#ln-37"></a><span class="c">!! Version: Experimental</span>
<a id="ln-38" name="ln-38" href="#ln-38"></a><span class="c">!!</span>
<a id="ln-39" name="ln-39" href="#ln-39"></a><span class="c">!! Interface to internal procedure that expands an open map's slots.</span>
<a id="ln-40" name="ln-40" href="#ln-40"></a><span class="w"> </span><span class="k">module procedure </span><span class="n">expand_open_slots</span>
<a id="ln-41" name="ln-41" href="#ln-41"></a><span class="w"> </span><span class="k">end interface </span><span class="n">expand_slots</span>
<a id="ln-42" name="ln-42" href="#ln-42"></a>
<a id="ln-43" name="ln-43" href="#ln-43"></a><span class="w"> </span><span class="k">interface </span><span class="n">extend_map_entry_pool</span>
<a id="ln-44" name="ln-44" href="#ln-44"></a><span class="c">!! Version: Experimental</span>
<a id="ln-45" name="ln-45" href="#ln-45"></a><span class="c">!!</span>
<a id="ln-46" name="ln-46" href="#ln-46"></a><span class="c">!! Interface to internal procedure that expands an open map entry pool.</span>
<a id="ln-47" name="ln-47" href="#ln-47"></a><span class="w"> </span><span class="k">module procedure </span><span class="n">extend_open_map_entry_pool</span>
<a id="ln-48" name="ln-48" href="#ln-48"></a><span class="w"> </span><span class="k">end interface </span><span class="n">extend_map_entry_pool</span>
<a id="ln-49" name="ln-49" href="#ln-49"></a>
<a id="ln-50" name="ln-50" href="#ln-50"></a><span class="w"> </span><span class="k">interface </span><span class="n">free_map</span>
<a id="ln-51" name="ln-51" href="#ln-51"></a><span class="c">!! Version: Experimental</span>
<a id="ln-52" name="ln-52" href="#ln-52"></a><span class="c">!!</span>
<a id="ln-53" name="ln-53" href="#ln-53"></a><span class="c">!! Interface to procedure that finalizes an open hash map.</span>
<a id="ln-54" name="ln-54" href="#ln-54"></a><span class="w"> </span><span class="k">module procedure </span><span class="n">free_open_map</span>
<a id="ln-55" name="ln-55" href="#ln-55"></a><span class="w"> </span><span class="k">end interface </span><span class="n">free_map</span>
<a id="ln-56" name="ln-56" href="#ln-56"></a>
<a id="ln-57" name="ln-57" href="#ln-57"></a><span class="w"> </span><span class="k">interface </span><span class="n">free_map_entry_pool</span>
<a id="ln-58" name="ln-58" href="#ln-58"></a><span class="c">!! Version: Experimental</span>
<a id="ln-59" name="ln-59" href="#ln-59"></a><span class="c">!!</span>
<a id="ln-60" name="ln-60" href="#ln-60"></a><span class="c">!! Interface to internal procedure that finalizes an open hash map</span>
<a id="ln-61" name="ln-61" href="#ln-61"></a><span class="c">!! entry pool.</span>
<a id="ln-62" name="ln-62" href="#ln-62"></a><span class="w"> </span><span class="k">module procedure </span><span class="n">free_map_entry_pool</span>
<a id="ln-63" name="ln-63" href="#ln-63"></a><span class="w"> </span><span class="k">end interface </span><span class="n">free_map_entry_pool</span>
<a id="ln-64" name="ln-64" href="#ln-64"></a>
<a id="ln-65" name="ln-65" href="#ln-65"></a><span class="w"> </span><span class="k">interface </span><span class="n">get_other_data</span>
<a id="ln-66" name="ln-66" href="#ln-66"></a><span class="c">!! Version: Experimental</span>
<a id="ln-67" name="ln-67" href="#ln-67"></a><span class="c">!!</span>
<a id="ln-68" name="ln-68" href="#ln-68"></a><span class="c">!! Interface to procedure that gets an entry's other data.</span>
<a id="ln-69" name="ln-69" href="#ln-69"></a><span class="w"> </span><span class="k">module procedure </span><span class="n">get_other_open_data</span>
<a id="ln-70" name="ln-70" href="#ln-70"></a><span class="w"> </span><span class="k">end interface </span><span class="n">get_other_data</span>
<a id="ln-71" name="ln-71" href="#ln-71"></a>
<a id="ln-72" name="ln-72" href="#ln-72"></a><span class="w"> </span><span class="k">interface </span><span class="n">init</span>
<a id="ln-73" name="ln-73" href="#ln-73"></a><span class="c">!! Version: Experimental</span>
<a id="ln-74" name="ln-74" href="#ln-74"></a><span class="c">!!</span>
<a id="ln-75" name="ln-75" href="#ln-75"></a><span class="c">!! Interface to initialization procedure for an open hash map.</span>
<a id="ln-76" name="ln-76" href="#ln-76"></a><span class="w"> </span><span class="k">module procedure </span><span class="n">init_open_map</span>
<a id="ln-77" name="ln-77" href="#ln-77"></a><span class="w"> </span><span class="k">end interface </span><span class="n">init</span>
<a id="ln-78" name="ln-78" href="#ln-78"></a>
<a id="ln-79" name="ln-79" href="#ln-79"></a><span class="w"> </span><span class="k">interface </span><span class="n">rehash</span>
<a id="ln-80" name="ln-80" href="#ln-80"></a><span class="c">!! Version: Experimental</span>
<a id="ln-81" name="ln-81" href="#ln-81"></a><span class="c">!!</span>
<a id="ln-82" name="ln-82" href="#ln-82"></a><span class="c">!! Interface to a procedure that changes the hash function that</span>
<a id="ln-83" name="ln-83" href="#ln-83"></a><span class="c">!! is used to map the keys into an open hash map.</span>
<a id="ln-84" name="ln-84" href="#ln-84"></a><span class="w"> </span><span class="k">module procedure </span><span class="n">rehash_open_map</span>
<a id="ln-85" name="ln-85" href="#ln-85"></a><span class="w"> </span><span class="k">end interface </span><span class="n">rehash</span>
<a id="ln-86" name="ln-86" href="#ln-86"></a>
<a id="ln-87" name="ln-87" href="#ln-87"></a><span class="w"> </span><span class="k">interface </span><span class="n">remove</span>
<a id="ln-88" name="ln-88" href="#ln-88"></a><span class="c">!! Version: Experimental</span>
<a id="ln-89" name="ln-89" href="#ln-89"></a><span class="c">!!</span>
<a id="ln-90" name="ln-90" href="#ln-90"></a><span class="c">!! Interface to a procedure that removees an entry from an open hash map.</span>
<a id="ln-91" name="ln-91" href="#ln-91"></a><span class="w"> </span><span class="k">module procedure </span><span class="n">remove_open_entry</span>
<a id="ln-92" name="ln-92" href="#ln-92"></a><span class="w"> </span><span class="k">end interface </span><span class="n">remove</span>
<a id="ln-93" name="ln-93" href="#ln-93"></a>
<a id="ln-94" name="ln-94" href="#ln-94"></a><span class="w"> </span><span class="k">interface </span><span class="n">set_other_data</span>
<a id="ln-95" name="ln-95" href="#ln-95"></a><span class="c">!! Version: Experimental</span>
<a id="ln-96" name="ln-96" href="#ln-96"></a><span class="c">!!</span>
<a id="ln-97" name="ln-97" href="#ln-97"></a><span class="c">!! Interface to a procedure that changes the other data associated with a key</span>
<a id="ln-98" name="ln-98" href="#ln-98"></a><span class="w"> </span><span class="k">module procedure </span><span class="n">set_other_open_data</span>
<a id="ln-99" name="ln-99" href="#ln-99"></a><span class="w"> </span><span class="k">end interface </span><span class="n">set_other_data</span>
<a id="ln-100" name="ln-100" href="#ln-100"></a>
<a id="ln-101" name="ln-101" href="#ln-101"></a><span class="k">contains</span>
<a id="ln-102" name="ln-102" href="#ln-102"></a>
<a id="ln-103" name="ln-103" href="#ln-103"></a>
<a id="ln-104" name="ln-104" href="#ln-104"></a><span class="k"> subroutine </span><span class="n">expand_open_slots</span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">)</span>
<a id="ln-105" name="ln-105" href="#ln-105"></a><span class="c">!! Version: Experimental</span>
<a id="ln-106" name="ln-106" href="#ln-106"></a><span class="c">!!</span>
<a id="ln-107" name="ln-107" href="#ln-107"></a><span class="c">!! Internal routine to make a duplicate map with more hash slots.</span>
<a id="ln-108" name="ln-108" href="#ln-108"></a><span class="c">!! Doubles the size of the map % slots array</span>
<a id="ln-109" name="ln-109" href="#ln-109"></a><span class="c">!! Arguments:</span>
<a id="ln-110" name="ln-110" href="#ln-110"></a><span class="c">!! map - the hash table whose hash slots are to be expanded</span>
<a id="ln-111" name="ln-111" href="#ln-111"></a><span class="c">!</span>
<a id="ln-112" name="ln-112" href="#ln-112"></a><span class="w"> </span><span class="k">type</span><span class="p">(</span><span class="n">open_hashmap_type</span><span class="p">),</span><span class="w"> </span><span class="k">intent</span><span class="p">(</span><span class="n">inout</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">map</span>
<a id="ln-113" name="ln-113" href="#ln-113"></a>
<a id="ln-114" name="ln-114" href="#ln-114"></a><span class="w"> </span><span class="kt">integer</span><span class="p">(</span><span class="n">int_hash</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">base_slot</span>
<a id="ln-115" name="ln-115" href="#ln-115"></a><span class="w"> </span><span class="kt">integer</span><span class="p">(</span><span class="n">int_index</span><span class="p">),</span><span class="w"> </span><span class="k">allocatable</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">dummy_slots</span><span class="p">(:)</span>
<a id="ln-116" name="ln-116" href="#ln-116"></a><span class="w"> </span><span class="kt">integer</span><span class="p">(</span><span class="n">int_index</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">inv_index</span><span class="p">,</span><span class="w"> </span><span class="p">&</span>
<a id="ln-117" name="ln-117" href="#ln-117"></a><span class="w"> </span><span class="n">new_size</span><span class="p">,</span><span class="w"> </span><span class="p">&</span>
<a id="ln-118" name="ln-118" href="#ln-118"></a><span class="w"> </span><span class="n">offset</span><span class="p">,</span><span class="w"> </span><span class="p">&</span>
<a id="ln-119" name="ln-119" href="#ln-119"></a><span class="w"> </span><span class="n">old_size</span><span class="p">,</span><span class="w"> </span><span class="p">&</span>
<a id="ln-120" name="ln-120" href="#ln-120"></a><span class="w"> </span><span class="n">test_slot</span>
<a id="ln-121" name="ln-121" href="#ln-121"></a><span class="w"> </span><span class="kt">integer</span><span class="p">(</span><span class="n">int32</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">bits</span><span class="p">,</span><span class="w"> </span><span class="p">&</span>
<a id="ln-122" name="ln-122" href="#ln-122"></a><span class="w"> </span><span class="nb">stat</span>
<a id="ln-123" name="ln-123" href="#ln-123"></a>
<a id="ln-124" name="ln-124" href="#ln-124"></a><span class="nb"> </span><span class="kt">character</span><span class="p">(</span><span class="mi">256</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">errmsg</span>
<a id="ln-125" name="ln-125" href="#ln-125"></a><span class="w"> </span><span class="kt">character</span><span class="p">(</span><span class="o">*</span><span class="p">),</span><span class="w"> </span><span class="k">parameter</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="k">procedure</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'EXPAND_SLOTS'</span>
<a id="ln-126" name="ln-126" href="#ln-126"></a>
<a id="ln-127" name="ln-127" href="#ln-127"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">nbits</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="n">max_bits</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
<a id="ln-128" name="ln-128" href="#ln-128"></a><span class="k"> error stop </span><span class="n">submodule_name</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="s1">' % '</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="k">procedure</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="s1">': '</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="p">&</span>
<a id="ln-129" name="ln-129" href="#ln-129"></a><span class="w"> </span><span class="n">expand_slots_fail</span>
<a id="ln-130" name="ln-130" href="#ln-130"></a><span class="w"> </span><span class="k">end if</span>
<a id="ln-131" name="ln-131" href="#ln-131"></a>
<a id="ln-132" name="ln-132" href="#ln-132"></a><span class="k"> </span><span class="n">old_size</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">size</span><span class="p">(</span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">slots</span><span class="p">,</span><span class="w"> </span><span class="nb">kind</span><span class="o">=</span><span class="n">int_index</span><span class="p">)</span>
<a id="ln-133" name="ln-133" href="#ln-133"></a>
<a id="ln-134" name="ln-134" href="#ln-134"></a><span class="w"> </span><span class="n">new_size</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="o">*</span><span class="n">old_size</span>
<a id="ln-135" name="ln-135" href="#ln-135"></a><span class="w"> </span><span class="n">bits</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">nbits</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span>
<a id="ln-136" name="ln-136" href="#ln-136"></a>
<a id="ln-137" name="ln-137" href="#ln-137"></a><span class="w"> </span><span class="k">allocate</span><span class="p">(</span><span class="w"> </span><span class="n">dummy_slots</span><span class="p">(</span><span class="mi">0</span><span class="p">:</span><span class="n">new_size</span><span class="o">-</span><span class="mi">1</span><span class="p">),</span><span class="w"> </span><span class="nb">stat</span><span class="o">=</span><span class="nb">stat</span><span class="p">,</span><span class="w"> </span><span class="n">errmsg</span><span class="o">=</span><span class="n">errmsg</span><span class="w"> </span><span class="p">)</span>
<a id="ln-138" name="ln-138" href="#ln-138"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nb">stat</span><span class="w"> </span><span class="o">/=</span><span class="w"> </span><span class="mi">0</span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
<a id="ln-139" name="ln-139" href="#ln-139"></a><span class="k"> error stop </span><span class="n">submodule_name</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="s1">' % '</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="k">procedure</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="s1">': '</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="p">&</span>
<a id="ln-140" name="ln-140" href="#ln-140"></a><span class="w"> </span><span class="n">alloc_slots_fault</span>
<a id="ln-141" name="ln-141" href="#ln-141"></a><span class="w"> </span><span class="k">end if</span>
<a id="ln-142" name="ln-142" href="#ln-142"></a>
<a id="ln-143" name="ln-143" href="#ln-143"></a><span class="k"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">nbits</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">bits</span>
<a id="ln-144" name="ln-144" href="#ln-144"></a>
<a id="ln-145" name="ln-145" href="#ln-145"></a><span class="w"> </span><span class="n">dummy_slots</span><span class="p">(:)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span>
<a id="ln-146" name="ln-146" href="#ln-146"></a><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">index_mask</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">new_size</span><span class="o">-</span><span class="mi">1</span>
<a id="ln-147" name="ln-147" href="#ln-147"></a>
<a id="ln-148" name="ln-148" href="#ln-148"></a><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">total_probes</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">total_probes</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">probe_count</span>
<a id="ln-149" name="ln-149" href="#ln-149"></a><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">probe_count</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span>
<a id="ln-150" name="ln-150" href="#ln-150"></a>
<a id="ln-151" name="ln-151" href="#ln-151"></a><span class="w"> </span><span class="n">REMAP_SLOTS</span><span class="p">:</span><span class="w"> </span><span class="k">do </span><span class="n">inv_index</span><span class="o">=</span><span class="mi">1_int_index</span><span class="p">,</span><span class="w"> </span><span class="p">&</span>
<a id="ln-152" name="ln-152" href="#ln-152"></a><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">num_entries</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">num_free</span>
<a id="ln-153" name="ln-153" href="#ln-153"></a><span class="w"> </span><span class="k">associate</span><span class="p">(</span><span class="w"> </span><span class="n">inverse</span><span class="w"> </span><span class="o">=></span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">inverse</span><span class="p">(</span><span class="n">inv_index</span><span class="p">)</span><span class="w"> </span><span class="p">)</span>
<a id="ln-154" name="ln-154" href="#ln-154"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="nb">associated</span><span class="p">(</span><span class="n">inverse</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="k">target</span><span class="p">)</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
<a id="ln-155" name="ln-155" href="#ln-155"></a><span class="k"> </span><span class="n">base_slot</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fibonacci_hash</span><span class="p">(</span><span class="w"> </span><span class="n">inverse</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="k">target</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">hash_val</span><span class="p">,</span><span class="w"> </span><span class="p">&</span>
<a id="ln-156" name="ln-156" href="#ln-156"></a><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">nbits</span><span class="w"> </span><span class="p">)</span>
<a id="ln-157" name="ln-157" href="#ln-157"></a><span class="w"> </span><span class="n">offset</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span>
<a id="ln-158" name="ln-158" href="#ln-158"></a><span class="w"> </span><span class="n">FIND_EMPTY_SLOT</span><span class="p">:</span><span class="w"> </span><span class="k">do</span>
<a id="ln-159" name="ln-159" href="#ln-159"></a><span class="k"> </span><span class="n">test_slot</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">iand</span><span class="p">(</span><span class="w"> </span><span class="nb">int</span><span class="p">(</span><span class="w"> </span><span class="n">base_slot</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">offset</span><span class="p">,</span><span class="w"> </span><span class="n">int_hash</span><span class="p">),</span><span class="w"> </span><span class="p">&</span>
<a id="ln-160" name="ln-160" href="#ln-160"></a><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">index_mask</span><span class="w"> </span><span class="p">)</span>
<a id="ln-161" name="ln-161" href="#ln-161"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="n">dummy_slots</span><span class="p">(</span><span class="n">test_slot</span><span class="p">)</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
<a id="ln-162" name="ln-162" href="#ln-162"></a><span class="k"> </span><span class="n">dummy_slots</span><span class="p">(</span><span class="n">test_slot</span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">inv_index</span>
<a id="ln-163" name="ln-163" href="#ln-163"></a><span class="w"> </span><span class="k">exit </span><span class="n">FIND_EMPTY_SLOT</span>
<a id="ln-164" name="ln-164" href="#ln-164"></a><span class="w"> </span><span class="k">end if</span>
<a id="ln-165" name="ln-165" href="#ln-165"></a><span class="k"> </span><span class="n">offset</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">offset</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span>
<a id="ln-166" name="ln-166" href="#ln-166"></a><span class="w"> </span><span class="k">end do </span><span class="n">FIND_EMPTY_SLOT</span>
<a id="ln-167" name="ln-167" href="#ln-167"></a><span class="w"> </span><span class="k">end if</span>
<a id="ln-168" name="ln-168" href="#ln-168"></a><span class="k"> end associate</span>
<a id="ln-169" name="ln-169" href="#ln-169"></a><span class="k"> end do </span><span class="n">REMAP_SLOTS</span>
<a id="ln-170" name="ln-170" href="#ln-170"></a>
<a id="ln-171" name="ln-171" href="#ln-171"></a><span class="w"> </span><span class="k">call </span><span class="nb">move_alloc</span><span class="p">(</span><span class="w"> </span><span class="n">dummy_slots</span><span class="p">,</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">slots</span><span class="w"> </span><span class="p">)</span>
<a id="ln-172" name="ln-172" href="#ln-172"></a>
<a id="ln-173" name="ln-173" href="#ln-173"></a><span class="w"> </span><span class="k">end subroutine </span><span class="n">expand_open_slots</span>
<a id="ln-174" name="ln-174" href="#ln-174"></a>
<a id="ln-175" name="ln-175" href="#ln-175"></a>
<a id="ln-176" name="ln-176" href="#ln-176"></a><span class="w"> </span><span class="k">subroutine </span><span class="n">extend_open_map_entry_pool</span><span class="p">(</span><span class="n">pool</span><span class="p">)</span><span class="w"> </span><span class="c">! gent_pool_new</span>
<a id="ln-177" name="ln-177" href="#ln-177"></a><span class="c">!! Version: Experimental</span>
<a id="ln-178" name="ln-178" href="#ln-178"></a><span class="c">!!</span>
<a id="ln-179" name="ln-179" href="#ln-179"></a><span class="c">!! Add more map_entrys to the pool head</span>
<a id="ln-180" name="ln-180" href="#ln-180"></a><span class="c">!! Arguments:</span>
<a id="ln-181" name="ln-181" href="#ln-181"></a><span class="c">!! pool - an open map entry pool</span>
<a id="ln-182" name="ln-182" href="#ln-182"></a><span class="w"> </span><span class="k">type</span><span class="p">(</span><span class="n">open_map_entry_pool</span><span class="p">),</span><span class="w"> </span><span class="k">intent</span><span class="p">(</span><span class="n">inout</span><span class="p">),</span><span class="w"> </span><span class="k">pointer</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">pool</span>
<a id="ln-183" name="ln-183" href="#ln-183"></a>
<a id="ln-184" name="ln-184" href="#ln-184"></a><span class="w"> </span><span class="k">type</span><span class="p">(</span><span class="n">open_map_entry_pool</span><span class="p">),</span><span class="w"> </span><span class="k">pointer</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">map_entry_pool_head</span>
<a id="ln-185" name="ln-185" href="#ln-185"></a>
<a id="ln-186" name="ln-186" href="#ln-186"></a><span class="w"> </span><span class="k">allocate</span><span class="p">(</span><span class="n">map_entry_pool_head</span><span class="p">)</span>
<a id="ln-187" name="ln-187" href="#ln-187"></a><span class="w"> </span><span class="k">allocate</span><span class="p">(</span><span class="n">map_entry_pool_head</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">more_map_entries</span><span class="p">(</span><span class="mi">0</span><span class="p">:</span><span class="n">pool_size</span><span class="o">-</span><span class="mi">1</span><span class="p">))</span>
<a id="ln-188" name="ln-188" href="#ln-188"></a><span class="w"> </span><span class="n">map_entry_pool_head</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">lastpool</span><span class="w"> </span><span class="o">=></span><span class="w"> </span><span class="n">pool</span>
<a id="ln-189" name="ln-189" href="#ln-189"></a><span class="w"> </span><span class="n">pool</span><span class="w"> </span><span class="o">=></span><span class="w"> </span><span class="n">map_entry_pool_head</span>
<a id="ln-190" name="ln-190" href="#ln-190"></a><span class="w"> </span><span class="n">pool</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">next</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span>
<a id="ln-191" name="ln-191" href="#ln-191"></a>
<a id="ln-192" name="ln-192" href="#ln-192"></a><span class="w"> </span><span class="k">end subroutine </span><span class="n">extend_open_map_entry_pool</span>
<a id="ln-193" name="ln-193" href="#ln-193"></a>
<a id="ln-194" name="ln-194" href="#ln-194"></a>
<a id="ln-195" name="ln-195" href="#ln-195"></a><span class="w"> </span><span class="k">recursive subroutine </span><span class="n">free_map_entry_pool</span><span class="p">(</span><span class="n">pool</span><span class="p">)</span><span class="w"> </span><span class="c">! gent_pool_free</span>
<a id="ln-196" name="ln-196" href="#ln-196"></a><span class="c">!! Version: Experimental</span>
<a id="ln-197" name="ln-197" href="#ln-197"></a><span class="c">!! Note the freeing of allocated memory may be unnecessary</span>
<a id="ln-198" name="ln-198" href="#ln-198"></a><span class="c">!!</span>
<a id="ln-199" name="ln-199" href="#ln-199"></a><span class="c">!! Recursively descends map entry pool list freeing each element</span>
<a id="ln-200" name="ln-200" href="#ln-200"></a><span class="c">!! Arguments:</span>
<a id="ln-201" name="ln-201" href="#ln-201"></a><span class="c">!! pool The map entry pool whose elements are to be freed</span>
<a id="ln-202" name="ln-202" href="#ln-202"></a><span class="c">!</span>
<a id="ln-203" name="ln-203" href="#ln-203"></a><span class="w"> </span><span class="k">type</span><span class="p">(</span><span class="n">open_map_entry_pool</span><span class="p">),</span><span class="w"> </span><span class="k">intent</span><span class="p">(</span><span class="n">inout</span><span class="p">),</span><span class="w"> </span><span class="k">pointer</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">pool</span>
<a id="ln-204" name="ln-204" href="#ln-204"></a>
<a id="ln-205" name="ln-205" href="#ln-205"></a><span class="w"> </span><span class="k">type</span><span class="p">(</span><span class="n">open_map_entry_pool</span><span class="p">),</span><span class="w"> </span><span class="k">pointer</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">lastpool</span>
<a id="ln-206" name="ln-206" href="#ln-206"></a>
<a id="ln-207" name="ln-207" href="#ln-207"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="nb">associated</span><span class="p">(</span><span class="n">pool</span><span class="p">)</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
<a id="ln-208" name="ln-208" href="#ln-208"></a><span class="k"> </span><span class="n">lastpool</span><span class="w"> </span><span class="o">=></span><span class="w"> </span><span class="n">pool</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">lastpool</span>
<a id="ln-209" name="ln-209" href="#ln-209"></a><span class="w"> </span><span class="n">pool</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">lastpool</span><span class="w"> </span><span class="o">=></span><span class="w"> </span><span class="nb">null</span><span class="p">()</span>
<a id="ln-210" name="ln-210" href="#ln-210"></a><span class="w"> </span><span class="k">deallocate</span><span class="p">(</span><span class="w"> </span><span class="n">pool</span><span class="w"> </span><span class="p">)</span>
<a id="ln-211" name="ln-211" href="#ln-211"></a><span class="c">! Trace component pointers/lists</span>
<a id="ln-212" name="ln-212" href="#ln-212"></a><span class="w"> </span><span class="k">call </span><span class="n">free_map_entry_pool</span><span class="p">(</span><span class="w"> </span><span class="n">lastpool</span><span class="w"> </span><span class="p">)</span>
<a id="ln-213" name="ln-213" href="#ln-213"></a><span class="w"> </span><span class="k">end if</span>
<a id="ln-214" name="ln-214" href="#ln-214"></a>
<a id="ln-215" name="ln-215" href="#ln-215"></a><span class="k"> end subroutine </span><span class="n">free_map_entry_pool</span>
<a id="ln-216" name="ln-216" href="#ln-216"></a>
<a id="ln-217" name="ln-217" href="#ln-217"></a>
<a id="ln-218" name="ln-218" href="#ln-218"></a><span class="w"> </span><span class="k">module subroutine </span><span class="n">free_open_map</span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">)</span>
<a id="ln-219" name="ln-219" href="#ln-219"></a><span class="c">!! Version: Experimental</span>
<a id="ln-220" name="ln-220" href="#ln-220"></a><span class="c">!!</span>
<a id="ln-221" name="ln-221" href="#ln-221"></a><span class="c">!! Frees internal memory of an open map</span>
<a id="ln-222" name="ln-222" href="#ln-222"></a><span class="c">!! Arguments:</span>
<a id="ln-223" name="ln-223" href="#ln-223"></a><span class="c">!! map - the open hash map whose memory is to be freed</span>
<a id="ln-224" name="ln-224" href="#ln-224"></a><span class="c">!</span>
<a id="ln-225" name="ln-225" href="#ln-225"></a><span class="w"> </span><span class="k">type</span><span class="p">(</span><span class="n">open_hashmap_type</span><span class="p">),</span><span class="w"> </span><span class="k">intent</span><span class="p">(</span><span class="n">inout</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">map</span>
<a id="ln-226" name="ln-226" href="#ln-226"></a>
<a id="ln-227" name="ln-227" href="#ln-227"></a><span class="w"> </span><span class="k">type</span><span class="p">(</span><span class="n">open_map_entry_list</span><span class="p">),</span><span class="w"> </span><span class="k">pointer</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">free_list</span>
<a id="ln-228" name="ln-228" href="#ln-228"></a><span class="w"> </span><span class="kt">integer</span><span class="p">(</span><span class="n">int_index</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">i</span>
<a id="ln-229" name="ln-229" href="#ln-229"></a>
<a id="ln-230" name="ln-230" href="#ln-230"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="nb">allocated</span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">slots</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
<a id="ln-231" name="ln-231" href="#ln-231"></a><span class="k"> deallocate</span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">slots</span><span class="w"> </span><span class="p">)</span>
<a id="ln-232" name="ln-232" href="#ln-232"></a><span class="w"> </span><span class="k">end if</span>
<a id="ln-233" name="ln-233" href="#ln-233"></a>
<a id="ln-234" name="ln-234" href="#ln-234"></a><span class="k"> if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="nb">allocated</span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">inverse</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
<a id="ln-235" name="ln-235" href="#ln-235"></a><span class="k"> </span><span class="n">remove_links</span><span class="p">:</span><span class="w"> </span><span class="k">do </span><span class="n">i</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="n">size</span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">inverse</span><span class="p">,</span><span class="w"> </span><span class="nb">kind</span><span class="o">=</span><span class="n">int_index</span><span class="w"> </span><span class="p">)</span>
<a id="ln-236" name="ln-236" href="#ln-236"></a><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">inverse</span><span class="p">(</span><span class="n">i</span><span class="p">)</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="k">target</span><span class="w"> </span><span class="o">=></span><span class="w"> </span><span class="nb">null</span><span class="p">()</span>
<a id="ln-237" name="ln-237" href="#ln-237"></a><span class="w"> </span><span class="k">end do </span><span class="n">remove_links</span>
<a id="ln-238" name="ln-238" href="#ln-238"></a><span class="w"> </span><span class="k">deallocate</span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">inverse</span><span class="w"> </span><span class="p">)</span>
<a id="ln-239" name="ln-239" href="#ln-239"></a><span class="w"> </span><span class="k">end if</span>
<a id="ln-240" name="ln-240" href="#ln-240"></a>
<a id="ln-241" name="ln-241" href="#ln-241"></a><span class="k"> </span><span class="n">free_free_list</span><span class="p">:</span><span class="w"> </span><span class="k">do while</span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">num_free</span><span class="w"> </span><span class="o">></span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="p">)</span>
<a id="ln-242" name="ln-242" href="#ln-242"></a><span class="w"> </span><span class="n">free_list</span><span class="w"> </span><span class="o">=></span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">free_list</span>
<a id="ln-243" name="ln-243" href="#ln-243"></a><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">free_list</span><span class="w"> </span><span class="o">=></span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">free_list</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">next</span>
<a id="ln-244" name="ln-244" href="#ln-244"></a><span class="w"> </span><span class="n">free_list</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">next</span><span class="w"> </span><span class="o">=></span><span class="w"> </span><span class="nb">null</span><span class="p">()</span>
<a id="ln-245" name="ln-245" href="#ln-245"></a><span class="w"> </span><span class="n">free_list</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="k">target</span><span class="w"> </span><span class="o">=></span><span class="w"> </span><span class="nb">null</span><span class="p">()</span>
<a id="ln-246" name="ln-246" href="#ln-246"></a><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">num_free</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">num_free</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mi">1</span>
<a id="ln-247" name="ln-247" href="#ln-247"></a><span class="w"> </span><span class="k">end do </span><span class="n">free_free_list</span>
<a id="ln-248" name="ln-248" href="#ln-248"></a><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">num_free</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span>
<a id="ln-249" name="ln-249" href="#ln-249"></a>
<a id="ln-250" name="ln-250" href="#ln-250"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="nb">associated</span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">cache</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">call </span><span class="n">free_map_entry_pool</span><span class="p">(</span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">cache</span><span class="p">)</span>
<a id="ln-251" name="ln-251" href="#ln-251"></a>
<a id="ln-252" name="ln-252" href="#ln-252"></a><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">num_entries</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span>
<a id="ln-253" name="ln-253" href="#ln-253"></a>
<a id="ln-254" name="ln-254" href="#ln-254"></a><span class="w"> </span><span class="k">end subroutine </span><span class="n">free_open_map</span>
<a id="ln-255" name="ln-255" href="#ln-255"></a>
<a id="ln-256" name="ln-256" href="#ln-256"></a>
<a id="ln-257" name="ln-257" href="#ln-257"></a><span class="w"> </span><span class="k">module subroutine </span><span class="n">get_all_open_keys</span><span class="p">(</span><span class="n">map</span><span class="p">,</span><span class="w"> </span><span class="n">all_keys</span><span class="p">)</span>
<a id="ln-258" name="ln-258" href="#ln-258"></a><span class="c">!! Version: Experimental</span>
<a id="ln-259" name="ln-259" href="#ln-259"></a><span class="c">!!</span>
<a id="ln-260" name="ln-260" href="#ln-260"></a><span class="c">!! Returns all the keys contained in a hash map</span>
<a id="ln-261" name="ln-261" href="#ln-261"></a><span class="c">!! Arguments:</span>
<a id="ln-262" name="ln-262" href="#ln-262"></a><span class="c">!! map - an open hash map</span>
<a id="ln-263" name="ln-263" href="#ln-263"></a><span class="c">!! all_keys - all the keys contained in a hash map</span>
<a id="ln-264" name="ln-264" href="#ln-264"></a><span class="c">!</span>
<a id="ln-265" name="ln-265" href="#ln-265"></a><span class="w"> </span><span class="k">class</span><span class="p">(</span><span class="n">open_hashmap_type</span><span class="p">),</span><span class="w"> </span><span class="k">intent</span><span class="p">(</span><span class="n">in</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">map</span>
<a id="ln-266" name="ln-266" href="#ln-266"></a><span class="w"> </span><span class="k">type</span><span class="p">(</span><span class="n">key_type</span><span class="p">),</span><span class="w"> </span><span class="k">allocatable</span><span class="p">,</span><span class="w"> </span><span class="k">intent</span><span class="p">(</span><span class="n">out</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">all_keys</span><span class="p">(:)</span>
<a id="ln-267" name="ln-267" href="#ln-267"></a><span class="w"> </span>
<a id="ln-268" name="ln-268" href="#ln-268"></a><span class="w"> </span><span class="kt">integer</span><span class="p">(</span><span class="n">int32</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">num_keys</span>
<a id="ln-269" name="ln-269" href="#ln-269"></a><span class="w"> </span><span class="kt">integer</span><span class="p">(</span><span class="n">int_index</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">i</span><span class="p">,</span><span class="w"> </span><span class="n">key_idx</span>
<a id="ln-270" name="ln-270" href="#ln-270"></a>
<a id="ln-271" name="ln-271" href="#ln-271"></a><span class="w"> </span><span class="n">num_keys</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">entries</span><span class="p">()</span>
<a id="ln-272" name="ln-272" href="#ln-272"></a><span class="w"> </span><span class="k">allocate</span><span class="p">(</span><span class="w"> </span><span class="n">all_keys</span><span class="p">(</span><span class="n">num_keys</span><span class="p">)</span><span class="w"> </span><span class="p">)</span>
<a id="ln-273" name="ln-273" href="#ln-273"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="n">num_keys</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">return</span>
<a id="ln-274" name="ln-274" href="#ln-274"></a>
<a id="ln-275" name="ln-275" href="#ln-275"></a><span class="k"> if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="nb">allocated</span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">inverse</span><span class="p">)</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
<a id="ln-276" name="ln-276" href="#ln-276"></a><span class="k"> </span><span class="n">key_idx</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1_int_index</span>
<a id="ln-277" name="ln-277" href="#ln-277"></a><span class="w"> </span><span class="k">do </span><span class="n">i</span><span class="o">=</span><span class="mi">1_int_index</span><span class="p">,</span><span class="w"> </span><span class="n">size</span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">inverse</span><span class="p">,</span><span class="w"> </span><span class="nb">kind</span><span class="o">=</span><span class="n">int_index</span><span class="w"> </span><span class="p">)</span>
<a id="ln-278" name="ln-278" href="#ln-278"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="nb">associated</span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">inverse</span><span class="p">(</span><span class="n">i</span><span class="p">)</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="k">target</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
<a id="ln-279" name="ln-279" href="#ln-279"></a><span class="k"> </span><span class="n">all_keys</span><span class="p">(</span><span class="n">key_idx</span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">inverse</span><span class="p">(</span><span class="n">i</span><span class="p">)</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="k">target</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">key</span>
<a id="ln-280" name="ln-280" href="#ln-280"></a><span class="w"> </span><span class="n">key_idx</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">key_idx</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1_int_index</span>
<a id="ln-281" name="ln-281" href="#ln-281"></a><span class="w"> </span><span class="k">end if</span>
<a id="ln-282" name="ln-282" href="#ln-282"></a><span class="k"> end do </span>
<a id="ln-283" name="ln-283" href="#ln-283"></a><span class="k"> end if</span>
<a id="ln-284" name="ln-284" href="#ln-284"></a>
<a id="ln-285" name="ln-285" href="#ln-285"></a><span class="k"> end subroutine </span><span class="n">get_all_open_keys</span>
<a id="ln-286" name="ln-286" href="#ln-286"></a>
<a id="ln-287" name="ln-287" href="#ln-287"></a>
<a id="ln-288" name="ln-288" href="#ln-288"></a><span class="w"> </span><span class="k">module subroutine </span><span class="n">get_other_open_data</span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="p">,</span><span class="w"> </span><span class="n">key</span><span class="p">,</span><span class="w"> </span><span class="n">other</span><span class="p">,</span><span class="w"> </span><span class="n">exists</span><span class="w"> </span><span class="p">)</span>
<a id="ln-289" name="ln-289" href="#ln-289"></a><span class="c">!! Version: Experimental</span>
<a id="ln-290" name="ln-290" href="#ln-290"></a><span class="c">!!</span>
<a id="ln-291" name="ln-291" href="#ln-291"></a><span class="c">!! Returns the other data associated with the inverse table index</span>
<a id="ln-292" name="ln-292" href="#ln-292"></a><span class="c">!! Arguments:</span>
<a id="ln-293" name="ln-293" href="#ln-293"></a><span class="c">!! map - an open hash table</span>
<a id="ln-294" name="ln-294" href="#ln-294"></a><span class="c">!! key - the key associated with a map entry</span>
<a id="ln-295" name="ln-295" href="#ln-295"></a><span class="c">!! other - the other data associated with the key</span>
<a id="ln-296" name="ln-296" href="#ln-296"></a><span class="c">!! exists - a logical flag indicating whether an entry with that key exists</span>
<a id="ln-297" name="ln-297" href="#ln-297"></a><span class="c">!</span>
<a id="ln-298" name="ln-298" href="#ln-298"></a><span class="w"> </span><span class="k">class</span><span class="p">(</span><span class="n">open_hashmap_type</span><span class="p">),</span><span class="w"> </span><span class="k">intent</span><span class="p">(</span><span class="n">inout</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">map</span>
<a id="ln-299" name="ln-299" href="#ln-299"></a><span class="w"> </span><span class="k">type</span><span class="p">(</span><span class="n">key_type</span><span class="p">),</span><span class="w"> </span><span class="k">intent</span><span class="p">(</span><span class="n">in</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">key</span>
<a id="ln-300" name="ln-300" href="#ln-300"></a><span class="w"> </span><span class="k">class</span><span class="p">(</span><span class="o">*</span><span class="p">),</span><span class="w"> </span><span class="k">allocatable</span><span class="p">,</span><span class="w"> </span><span class="k">intent</span><span class="p">(</span><span class="n">out</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">other</span>
<a id="ln-301" name="ln-301" href="#ln-301"></a><span class="w"> </span><span class="kt">logical</span><span class="p">,</span><span class="w"> </span><span class="k">intent</span><span class="p">(</span><span class="n">out</span><span class="p">),</span><span class="w"> </span><span class="k">optional</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">exists</span>
<a id="ln-302" name="ln-302" href="#ln-302"></a>
<a id="ln-303" name="ln-303" href="#ln-303"></a><span class="w"> </span><span class="kt">integer</span><span class="p">(</span><span class="n">int_index</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">inmap</span>
<a id="ln-304" name="ln-304" href="#ln-304"></a><span class="w"> </span><span class="kt">character</span><span class="p">(</span><span class="o">*</span><span class="p">),</span><span class="w"> </span><span class="k">parameter</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="k">procedure</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'GET_OTHER_DATA'</span>
<a id="ln-305" name="ln-305" href="#ln-305"></a>
<a id="ln-306" name="ln-306" href="#ln-306"></a><span class="w"> </span><span class="k">call </span><span class="n">in_open_map</span><span class="p">(</span><span class="n">map</span><span class="p">,</span><span class="w"> </span><span class="n">inmap</span><span class="p">,</span><span class="w"> </span><span class="n">key</span><span class="p">)</span>
<a id="ln-307" name="ln-307" href="#ln-307"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="n">inmap</span><span class="w"> </span><span class="o"><=</span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="p">.</span><span class="nb">or</span><span class="p">.</span><span class="w"> </span><span class="p">&</span>
<a id="ln-308" name="ln-308" href="#ln-308"></a><span class="w"> </span><span class="n">inmap</span><span class="w"> </span><span class="o">></span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">num_entries</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">num_free</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
<a id="ln-309" name="ln-309" href="#ln-309"></a><span class="k"> if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="nb">present</span><span class="p">(</span><span class="n">exists</span><span class="p">)</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
<a id="ln-310" name="ln-310" href="#ln-310"></a><span class="k"> </span><span class="n">exists</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">.</span><span class="n">false</span><span class="p">.</span>
<a id="ln-311" name="ln-311" href="#ln-311"></a><span class="w"> </span><span class="k">return</span>
<a id="ln-312" name="ln-312" href="#ln-312"></a><span class="k"> else</span>
<a id="ln-313" name="ln-313" href="#ln-313"></a><span class="k"> error stop </span><span class="n">submodule_name</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="s1">' % '</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="k">procedure</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="s1">': '</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="p">&</span>
<a id="ln-314" name="ln-314" href="#ln-314"></a><span class="w"> </span><span class="n">invalid_inmap</span>
<a id="ln-315" name="ln-315" href="#ln-315"></a><span class="w"> </span><span class="k">end if</span>
<a id="ln-316" name="ln-316" href="#ln-316"></a><span class="k"> else if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="nb">associated</span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">inverse</span><span class="p">(</span><span class="n">inmap</span><span class="p">)</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="k">target</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
<a id="ln-317" name="ln-317" href="#ln-317"></a><span class="k"> if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="nb">present</span><span class="p">(</span><span class="n">exists</span><span class="p">)</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="n">exists</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">.</span><span class="n">true</span><span class="p">.</span>
<a id="ln-318" name="ln-318" href="#ln-318"></a><span class="w"> </span><span class="n">other</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">inverse</span><span class="p">(</span><span class="n">inmap</span><span class="p">)</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="k">target</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">other</span>
<a id="ln-319" name="ln-319" href="#ln-319"></a><span class="w"> </span><span class="k">else</span>
<a id="ln-320" name="ln-320" href="#ln-320"></a><span class="k"> if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="nb">present</span><span class="p">(</span><span class="n">exists</span><span class="p">)</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
<a id="ln-321" name="ln-321" href="#ln-321"></a><span class="k"> </span><span class="n">exists</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">.</span><span class="n">false</span><span class="p">.</span>
<a id="ln-322" name="ln-322" href="#ln-322"></a><span class="w"> </span><span class="k">return</span>
<a id="ln-323" name="ln-323" href="#ln-323"></a><span class="k"> else</span>
<a id="ln-324" name="ln-324" href="#ln-324"></a><span class="k"> error stop </span><span class="n">submodule_name</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="s1">' % '</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="k">procedure</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="s1">': '</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="p">&</span>
<a id="ln-325" name="ln-325" href="#ln-325"></a><span class="w"> </span><span class="n">map_consist_fault</span>
<a id="ln-326" name="ln-326" href="#ln-326"></a><span class="w"> </span><span class="k">end if</span>
<a id="ln-327" name="ln-327" href="#ln-327"></a><span class="k"> end if</span>
<a id="ln-328" name="ln-328" href="#ln-328"></a>
<a id="ln-329" name="ln-329" href="#ln-329"></a><span class="k"> end subroutine </span><span class="n">get_other_open_data</span>
<a id="ln-330" name="ln-330" href="#ln-330"></a>
<a id="ln-331" name="ln-331" href="#ln-331"></a>
<a id="ln-332" name="ln-332" href="#ln-332"></a><span class="w"> </span><span class="k">subroutine </span><span class="n">in_open_map</span><span class="p">(</span><span class="n">map</span><span class="p">,</span><span class="w"> </span><span class="n">inmap</span><span class="p">,</span><span class="w"> </span><span class="n">key</span><span class="p">)</span><span class="w"> </span><span class="c">! Chase's inmap</span>
<a id="ln-333" name="ln-333" href="#ln-333"></a><span class="c">!! Version: Experimental</span>
<a id="ln-334" name="ln-334" href="#ln-334"></a><span class="c">!!</span>
<a id="ln-335" name="ln-335" href="#ln-335"></a><span class="c">!! Returns the index into the INVERSE array associated with the KEY</span>
<a id="ln-336" name="ln-336" href="#ln-336"></a><span class="c">!! Arguments:</span>
<a id="ln-337" name="ln-337" href="#ln-337"></a><span class="c">!! map - the hash map of interest</span>
<a id="ln-338" name="ln-338" href="#ln-338"></a><span class="c">!! inmap - the returned index into the INVERSE array of entry pointers</span>
<a id="ln-339" name="ln-339" href="#ln-339"></a><span class="c">!! key - the key identifying the entry of interest</span>
<a id="ln-340" name="ln-340" href="#ln-340"></a><span class="c">!</span>
<a id="ln-341" name="ln-341" href="#ln-341"></a><span class="w"> </span><span class="k">class</span><span class="p">(</span><span class="n">open_hashmap_type</span><span class="p">),</span><span class="w"> </span><span class="k">intent</span><span class="p">(</span><span class="n">inout</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">map</span>
<a id="ln-342" name="ln-342" href="#ln-342"></a><span class="w"> </span><span class="kt">integer</span><span class="p">(</span><span class="n">int_index</span><span class="p">),</span><span class="w"> </span><span class="k">intent</span><span class="p">(</span><span class="n">out</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">inmap</span>
<a id="ln-343" name="ln-343" href="#ln-343"></a><span class="w"> </span><span class="k">type</span><span class="p">(</span><span class="n">key_type</span><span class="p">),</span><span class="w"> </span><span class="k">intent</span><span class="p">(</span><span class="n">in</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">key</span>
<a id="ln-344" name="ln-344" href="#ln-344"></a>
<a id="ln-345" name="ln-345" href="#ln-345"></a><span class="w"> </span><span class="kt">character</span><span class="p">(</span><span class="o">*</span><span class="p">),</span><span class="w"> </span><span class="k">parameter</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="k">procedure</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'IN_MAP'</span>
<a id="ln-346" name="ln-346" href="#ln-346"></a><span class="w"> </span><span class="kt">integer</span><span class="p">(</span><span class="n">int_hash</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="p">&</span>
<a id="ln-347" name="ln-347" href="#ln-347"></a><span class="w"> </span><span class="n">base_slot</span><span class="p">,</span><span class="w"> </span><span class="p">&</span>
<a id="ln-348" name="ln-348" href="#ln-348"></a><span class="w"> </span><span class="n">hash_val</span><span class="p">,</span><span class="w"> </span><span class="p">&</span>
<a id="ln-349" name="ln-349" href="#ln-349"></a><span class="w"> </span><span class="n">test_slot</span>
<a id="ln-350" name="ln-350" href="#ln-350"></a><span class="w"> </span><span class="kt">integer</span><span class="p">(</span><span class="n">int_index</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="p">&</span>
<a id="ln-351" name="ln-351" href="#ln-351"></a><span class="w"> </span><span class="n">offset</span>
<a id="ln-352" name="ln-352" href="#ln-352"></a>
<a id="ln-353" name="ln-353" href="#ln-353"></a><span class="w"> </span><span class="n">hash_val</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">hasher</span><span class="p">(</span><span class="w"> </span><span class="n">key</span><span class="w"> </span><span class="p">)</span>
<a id="ln-354" name="ln-354" href="#ln-354"></a>
<a id="ln-355" name="ln-355" href="#ln-355"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">probe_count</span><span class="w"> </span><span class="o">></span><span class="w"> </span><span class="n">inmap_probe_factor</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">call_count</span><span class="w"> </span><span class="p">.</span><span class="nb">or</span><span class="p">.</span><span class="w"> </span><span class="p">&</span>
<a id="ln-356" name="ln-356" href="#ln-356"></a><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">num_entries</span><span class="w"> </span><span class="o">>=</span><span class="w"> </span><span class="n">load_factor</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="p">&</span>
<a id="ln-357" name="ln-357" href="#ln-357"></a><span class="w"> </span><span class="n">size</span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">slots</span><span class="p">,</span><span class="w"> </span><span class="nb">kind</span><span class="o">=</span><span class="n">int_index</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
<a id="ln-358" name="ln-358" href="#ln-358"></a><span class="k"> if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">nbits</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="n">max_bits</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="p">&</span>
<a id="ln-359" name="ln-359" href="#ln-359"></a><span class="w"> </span><span class="k">call </span><span class="n">expand_slots</span><span class="p">(</span><span class="n">map</span><span class="p">)</span>
<a id="ln-360" name="ln-360" href="#ln-360"></a><span class="w"> </span><span class="k">end if</span>
<a id="ln-361" name="ln-361" href="#ln-361"></a>
<a id="ln-362" name="ln-362" href="#ln-362"></a><span class="k"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">call_count</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">call_count</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span>
<a id="ln-363" name="ln-363" href="#ln-363"></a><span class="w"> </span><span class="n">base_slot</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fibonacci_hash</span><span class="p">(</span><span class="w"> </span><span class="n">hash_val</span><span class="p">,</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">nbits</span><span class="w"> </span><span class="p">)</span>
<a id="ln-364" name="ln-364" href="#ln-364"></a><span class="w"> </span><span class="n">offset</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0_int_index</span>
<a id="ln-365" name="ln-365" href="#ln-365"></a><span class="w"> </span><span class="n">PROBE_SLOTS</span><span class="p">:</span><span class="w"> </span><span class="k">do</span>
<a id="ln-366" name="ln-366" href="#ln-366"></a><span class="k"> </span><span class="n">test_slot</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">iand</span><span class="p">(</span><span class="w"> </span><span class="n">base_slot</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">offset</span><span class="p">,</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">index_mask</span><span class="w"> </span><span class="p">)</span>
<a id="ln-367" name="ln-367" href="#ln-367"></a><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">probe_count</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">probe_count</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span>
<a id="ln-368" name="ln-368" href="#ln-368"></a><span class="w"> </span><span class="n">inmap</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">slots</span><span class="p">(</span><span class="w"> </span><span class="n">test_slot</span><span class="w"> </span><span class="p">)</span>
<a id="ln-369" name="ln-369" href="#ln-369"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="n">inmap</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
<a id="ln-370" name="ln-370" href="#ln-370"></a><span class="k"> return</span>
<a id="ln-371" name="ln-371" href="#ln-371"></a><span class="k"> else if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="n">inmap</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="p">.</span><span class="nb">or</span><span class="p">.</span><span class="w"> </span><span class="p">&</span>
<a id="ln-372" name="ln-372" href="#ln-372"></a><span class="w"> </span><span class="n">inmap</span><span class="w"> </span><span class="o">></span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">num_entries</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">num_free</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
<a id="ln-373" name="ln-373" href="#ln-373"></a><span class="k"> error stop </span><span class="n">submodule_name</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="s1">' % '</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="k">procedure</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="s1">': '</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="p">&</span>
<a id="ln-374" name="ln-374" href="#ln-374"></a><span class="w"> </span><span class="n">map_consist_fault</span>
<a id="ln-375" name="ln-375" href="#ln-375"></a><span class="w"> </span><span class="k">else if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="p">.</span><span class="nb">not</span><span class="p">.</span><span class="w"> </span><span class="nb">associated</span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">inverse</span><span class="p">(</span><span class="n">inmap</span><span class="p">)</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="k">target</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
<a id="ln-376" name="ln-376" href="#ln-376"></a><span class="k"> error stop </span><span class="n">submodule_name</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="s1">' % '</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="k">procedure</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="s1">': '</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="p">&</span>
<a id="ln-377" name="ln-377" href="#ln-377"></a><span class="w"> </span><span class="n">map_consist_fault</span>
<a id="ln-378" name="ln-378" href="#ln-378"></a><span class="w"> </span><span class="k">else</span>
<a id="ln-379" name="ln-379" href="#ln-379"></a><span class="k"> associate</span><span class="p">(</span><span class="w"> </span><span class="n">inverse</span><span class="w"> </span><span class="o">=></span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">inverse</span><span class="p">(</span><span class="n">inmap</span><span class="p">)</span><span class="w"> </span><span class="p">)</span>
<a id="ln-380" name="ln-380" href="#ln-380"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="n">hash_val</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="n">inverse</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="k">target</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">hash_val</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
<a id="ln-381" name="ln-381" href="#ln-381"></a><span class="k"> if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="n">key</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="n">inverse</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="k">target</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">key</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
<a id="ln-382" name="ln-382" href="#ln-382"></a><span class="k"> return</span>
<a id="ln-383" name="ln-383" href="#ln-383"></a><span class="k"> end if</span>
<a id="ln-384" name="ln-384" href="#ln-384"></a><span class="k"> end if</span>
<a id="ln-385" name="ln-385" href="#ln-385"></a><span class="k"> end associate</span>
<a id="ln-386" name="ln-386" href="#ln-386"></a><span class="k"> end if</span>
<a id="ln-387" name="ln-387" href="#ln-387"></a><span class="k"> </span><span class="n">offset</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">offset</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1_int_index</span>
<a id="ln-388" name="ln-388" href="#ln-388"></a><span class="w"> </span><span class="k">end do </span><span class="n">PROBE_SLOTS</span>
<a id="ln-389" name="ln-389" href="#ln-389"></a>
<a id="ln-390" name="ln-390" href="#ln-390"></a><span class="w"> </span><span class="k">end subroutine </span><span class="n">in_open_map</span>
<a id="ln-391" name="ln-391" href="#ln-391"></a>
<a id="ln-392" name="ln-392" href="#ln-392"></a>
<a id="ln-393" name="ln-393" href="#ln-393"></a><span class="w"> </span><span class="k">module subroutine </span><span class="n">init_open_map</span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="p">,</span><span class="w"> </span><span class="p">&</span>
<a id="ln-394" name="ln-394" href="#ln-394"></a><span class="w"> </span><span class="n">hasher</span><span class="p">,</span><span class="w"> </span><span class="p">&</span>
<a id="ln-395" name="ln-395" href="#ln-395"></a><span class="w"> </span><span class="n">slots_bits</span><span class="p">,</span><span class="w"> </span><span class="p">&</span>
<a id="ln-396" name="ln-396" href="#ln-396"></a><span class="w"> </span><span class="n">status</span><span class="w"> </span><span class="p">)</span>
<a id="ln-397" name="ln-397" href="#ln-397"></a><span class="c">!! Version: Experimental</span>
<a id="ln-398" name="ln-398" href="#ln-398"></a><span class="c">!!</span>
<a id="ln-399" name="ln-399" href="#ln-399"></a><span class="c">!! Routine to allocate an empty map with HASHER as the hash function,</span>
<a id="ln-400" name="ln-400" href="#ln-400"></a><span class="c">!! 2**SLOTS_BITS initial SIZE(map % slots), and SIZE(map % slots) limited to a</span>
<a id="ln-401" name="ln-401" href="#ln-401"></a><span class="c">!! maximum of 2**MAX_BITS. All fields are initialized.</span>
<a id="ln-402" name="ln-402" href="#ln-402"></a><span class="c">!! Arguments:</span>
<a id="ln-403" name="ln-403" href="#ln-403"></a><span class="c">!! map - the open hash maap to be initialized</span>
<a id="ln-404" name="ln-404" href="#ln-404"></a><span class="c">!! hasher - the hash function to be used to map keys to slots</span>
<a id="ln-405" name="ln-405" href="#ln-405"></a><span class="c">!! slots_bits - the number of bits used to map to the slots</span>
<a id="ln-406" name="ln-406" href="#ln-406"></a><span class="c">!! status - an integer error status flag with the allowed values:</span>
<a id="ln-407" name="ln-407" href="#ln-407"></a><span class="c">!! success - no problems were found</span>
<a id="ln-408" name="ln-408" href="#ln-408"></a><span class="c">!! alloc_fault - map % slots or map % inverse could not be allocated</span>
<a id="ln-409" name="ln-409" href="#ln-409"></a><span class="c">!! array_size_error - slots_bits is less than default_bitd or</span>
<a id="ln-410" name="ln-410" href="#ln-410"></a><span class="c">!! greater than max_bits</span>
<a id="ln-411" name="ln-411" href="#ln-411"></a>
<a id="ln-412" name="ln-412" href="#ln-412"></a><span class="w"> </span><span class="k">class</span><span class="p">(</span><span class="n">open_hashmap_type</span><span class="p">),</span><span class="w"> </span><span class="k">intent</span><span class="p">(</span><span class="n">out</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">map</span>
<a id="ln-413" name="ln-413" href="#ln-413"></a><span class="w"> </span><span class="k">procedure</span><span class="p">(</span><span class="n">hasher_fun</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">hasher</span>
<a id="ln-414" name="ln-414" href="#ln-414"></a><span class="w"> </span><span class="kt">integer</span><span class="p">,</span><span class="w"> </span><span class="k">intent</span><span class="p">(</span><span class="n">in</span><span class="p">),</span><span class="w"> </span><span class="k">optional</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">slots_bits</span>
<a id="ln-415" name="ln-415" href="#ln-415"></a><span class="w"> </span><span class="kt">integer</span><span class="p">(</span><span class="n">int32</span><span class="p">),</span><span class="w"> </span><span class="k">intent</span><span class="p">(</span><span class="n">out</span><span class="p">),</span><span class="w"> </span><span class="k">optional</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">status</span>
<a id="ln-416" name="ln-416" href="#ln-416"></a>
<a id="ln-417" name="ln-417" href="#ln-417"></a><span class="w"> </span><span class="kt">character</span><span class="p">(</span><span class="mi">256</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">errmsg</span>
<a id="ln-418" name="ln-418" href="#ln-418"></a><span class="w"> </span><span class="kt">integer</span><span class="p">(</span><span class="n">int_index</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">i</span>
<a id="ln-419" name="ln-419" href="#ln-419"></a><span class="w"> </span><span class="kt">character</span><span class="p">(</span><span class="o">*</span><span class="p">),</span><span class="w"> </span><span class="k">parameter</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="k">procedure</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'INIT'</span>
<a id="ln-420" name="ln-420" href="#ln-420"></a><span class="w"> </span><span class="kt">integer</span><span class="p">(</span><span class="n">int_index</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">slots</span>
<a id="ln-421" name="ln-421" href="#ln-421"></a><span class="w"> </span><span class="kt">integer</span><span class="p">(</span><span class="n">int32</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="nb">stat</span>
<a id="ln-422" name="ln-422" href="#ln-422"></a><span class="nb"> </span><span class="k">type</span><span class="p">(</span><span class="n">open_map_entry_pool</span><span class="p">),</span><span class="w"> </span><span class="k">pointer</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">map_entry_pool_head</span>
<a id="ln-423" name="ln-423" href="#ln-423"></a>
<a id="ln-424" name="ln-424" href="#ln-424"></a><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">call_count</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span>
<a id="ln-425" name="ln-425" href="#ln-425"></a><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">probe_count</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span>
<a id="ln-426" name="ln-426" href="#ln-426"></a><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">total_probes</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span>
<a id="ln-427" name="ln-427" href="#ln-427"></a>
<a id="ln-428" name="ln-428" href="#ln-428"></a><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">hasher</span><span class="w"> </span><span class="o">=></span><span class="w"> </span><span class="n">hasher</span>
<a id="ln-429" name="ln-429" href="#ln-429"></a>
<a id="ln-430" name="ln-430" href="#ln-430"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="nb">present</span><span class="p">(</span><span class="n">slots_bits</span><span class="p">)</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
<a id="ln-431" name="ln-431" href="#ln-431"></a><span class="k"> if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="n">slots_bits</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="n">default_bits</span><span class="w"> </span><span class="p">.</span><span class="nb">OR</span><span class="p">.</span><span class="w"> </span><span class="p">&</span>
<a id="ln-432" name="ln-432" href="#ln-432"></a><span class="w"> </span><span class="n">slots_bits</span><span class="w"> </span><span class="o">></span><span class="w"> </span><span class="n">max_bits</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
<a id="ln-433" name="ln-433" href="#ln-433"></a><span class="k"> if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="nb">present</span><span class="p">(</span><span class="n">status</span><span class="p">)</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
<a id="ln-434" name="ln-434" href="#ln-434"></a><span class="k"> </span><span class="n">status</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">array_size_error</span>
<a id="ln-435" name="ln-435" href="#ln-435"></a><span class="w"> </span><span class="k">return</span>
<a id="ln-436" name="ln-436" href="#ln-436"></a><span class="k"> else</span>
<a id="ln-437" name="ln-437" href="#ln-437"></a><span class="k"> error stop </span><span class="n">submodule_name</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="s1">' % '</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="k">procedure</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="s1">': '</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="p">&</span>
<a id="ln-438" name="ln-438" href="#ln-438"></a><span class="w"> </span><span class="n">init_slots_pow_fail</span>
<a id="ln-439" name="ln-439" href="#ln-439"></a><span class="w"> </span><span class="k">end if</span>
<a id="ln-440" name="ln-440" href="#ln-440"></a><span class="k"> end if</span>
<a id="ln-441" name="ln-441" href="#ln-441"></a><span class="k"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">nbits</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">slots_bits</span>
<a id="ln-442" name="ln-442" href="#ln-442"></a><span class="w"> </span><span class="k">else</span>
<a id="ln-443" name="ln-443" href="#ln-443"></a><span class="k"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">nbits</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">min</span><span class="p">(</span><span class="w"> </span><span class="n">default_bits</span><span class="p">,</span><span class="w"> </span><span class="n">max_bits</span><span class="w"> </span><span class="p">)</span>
<a id="ln-444" name="ln-444" href="#ln-444"></a><span class="w"> </span><span class="k">end if</span>
<a id="ln-445" name="ln-445" href="#ln-445"></a>
<a id="ln-446" name="ln-446" href="#ln-446"></a><span class="k"> </span><span class="n">slots</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2_int32</span><span class="o">**</span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">nbits</span>
<a id="ln-447" name="ln-447" href="#ln-447"></a><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">index_mask</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">slots</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mi">1</span>
<a id="ln-448" name="ln-448" href="#ln-448"></a>
<a id="ln-449" name="ln-449" href="#ln-449"></a><span class="w"> </span><span class="k">allocate</span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">slots</span><span class="p">(</span><span class="mi">0</span><span class="p">:</span><span class="n">slots</span><span class="o">-</span><span class="mi">1</span><span class="p">),</span><span class="w"> </span><span class="nb">stat</span><span class="o">=</span><span class="nb">stat</span><span class="p">,</span><span class="w"> </span><span class="n">errmsg</span><span class="o">=</span><span class="n">errmsg</span><span class="w"> </span><span class="p">)</span>
<a id="ln-450" name="ln-450" href="#ln-450"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="nb">stat</span><span class="w"> </span><span class="o">/=</span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
<a id="ln-451" name="ln-451" href="#ln-451"></a><span class="k"> if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="nb">present</span><span class="p">(</span><span class="n">status</span><span class="p">)</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
<a id="ln-452" name="ln-452" href="#ln-452"></a><span class="k"> </span><span class="n">status</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">alloc_fault</span>
<a id="ln-453" name="ln-453" href="#ln-453"></a><span class="w"> </span><span class="k">return</span>
<a id="ln-454" name="ln-454" href="#ln-454"></a><span class="k"> else</span>
<a id="ln-455" name="ln-455" href="#ln-455"></a><span class="k"> write</span><span class="p">(</span><span class="n">error_unit</span><span class="p">,</span><span class="w"> </span><span class="s1">'(a)'</span><span class="p">)</span><span class="w"> </span><span class="s1">'Allocation ERRMSG: '</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="nb">trim</span><span class="p">(</span><span class="n">errmsg</span><span class="p">)</span>
<a id="ln-456" name="ln-456" href="#ln-456"></a><span class="w"> </span><span class="k">error stop </span><span class="n">submodule_name</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="s1">' % '</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="k">procedure</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="s1">': '</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="p">&</span>
<a id="ln-457" name="ln-457" href="#ln-457"></a><span class="w"> </span><span class="n">alloc_slots_fault</span>
<a id="ln-458" name="ln-458" href="#ln-458"></a><span class="w"> </span><span class="k">end if</span>
<a id="ln-459" name="ln-459" href="#ln-459"></a><span class="k"> end if</span>
<a id="ln-460" name="ln-460" href="#ln-460"></a>
<a id="ln-461" name="ln-461" href="#ln-461"></a><span class="k"> do </span><span class="n">i</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span><span class="w"> </span><span class="n">size</span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">slots</span><span class="p">,</span><span class="w"> </span><span class="nb">kind</span><span class="o">=</span><span class="n">int_index</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mi">1</span>
<a id="ln-462" name="ln-462" href="#ln-462"></a><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">slots</span><span class="p">(</span><span class="n">i</span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="c">! May be redundant</span>
<a id="ln-463" name="ln-463" href="#ln-463"></a><span class="w"> </span><span class="k">end do</span>
<a id="ln-464" name="ln-464" href="#ln-464"></a>
<a id="ln-465" name="ln-465" href="#ln-465"></a><span class="c">!! 5*s from Chase's g_new_map</span>
<a id="ln-466" name="ln-466" href="#ln-466"></a><span class="w"> </span><span class="k">allocate</span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">inverse</span><span class="p">(</span><span class="mi">1</span><span class="p">:</span><span class="nb">ceiling</span><span class="p">(</span><span class="n">load_factor</span><span class="o">*</span><span class="n">slots</span><span class="p">,</span><span class="w"> </span><span class="p">&</span>
<a id="ln-467" name="ln-467" href="#ln-467"></a><span class="w"> </span><span class="nb">kind</span><span class="o">=</span><span class="n">int_index</span><span class="p">)),</span><span class="w"> </span><span class="p">&</span>
<a id="ln-468" name="ln-468" href="#ln-468"></a><span class="w"> </span><span class="nb">stat</span><span class="o">=</span><span class="nb">stat</span><span class="p">,</span><span class="w"> </span><span class="p">&</span>
<a id="ln-469" name="ln-469" href="#ln-469"></a><span class="w"> </span><span class="n">errmsg</span><span class="o">=</span><span class="n">errmsg</span><span class="w"> </span><span class="p">)</span>
<a id="ln-470" name="ln-470" href="#ln-470"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="nb">stat</span><span class="w"> </span><span class="o">/=</span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
<a id="ln-471" name="ln-471" href="#ln-471"></a><span class="k"> if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="nb">present</span><span class="p">(</span><span class="w"> </span><span class="n">status</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
<a id="ln-472" name="ln-472" href="#ln-472"></a><span class="k"> </span><span class="n">status</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">alloc_fault</span>
<a id="ln-473" name="ln-473" href="#ln-473"></a><span class="w"> </span><span class="k">return</span>
<a id="ln-474" name="ln-474" href="#ln-474"></a><span class="k"> else</span>
<a id="ln-475" name="ln-475" href="#ln-475"></a><span class="k"> write</span><span class="p">(</span><span class="n">error_unit</span><span class="p">,</span><span class="w"> </span><span class="s1">'(a)'</span><span class="p">)</span><span class="w"> </span><span class="s1">'Allocation ERRMSG: '</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="nb">trim</span><span class="p">(</span><span class="n">errmsg</span><span class="p">)</span>
<a id="ln-476" name="ln-476" href="#ln-476"></a><span class="w"> </span><span class="k">error stop </span><span class="n">submodule_name</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="s1">' % '</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="k">procedure</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="s1">': '</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="p">&</span>
<a id="ln-477" name="ln-477" href="#ln-477"></a><span class="w"> </span><span class="n">alloc_inv_fault</span>
<a id="ln-478" name="ln-478" href="#ln-478"></a><span class="w"> </span><span class="k">end if</span>
<a id="ln-479" name="ln-479" href="#ln-479"></a><span class="k"> end if</span>
<a id="ln-480" name="ln-480" href="#ln-480"></a>
<a id="ln-481" name="ln-481" href="#ln-481"></a><span class="k"> do </span><span class="n">i</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="n">size</span><span class="p">(</span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">inverse</span><span class="p">,</span><span class="w"> </span><span class="nb">kind</span><span class="o">=</span><span class="n">int_index</span><span class="p">)</span>
<a id="ln-482" name="ln-482" href="#ln-482"></a><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">inverse</span><span class="p">(</span><span class="n">i</span><span class="p">)</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="k">target</span><span class="w"> </span><span class="o">=></span><span class="w"> </span><span class="nb">null</span><span class="p">()</span>
<a id="ln-483" name="ln-483" href="#ln-483"></a><span class="w"> </span><span class="k">end do</span>
<a id="ln-484" name="ln-484" href="#ln-484"></a>
<a id="ln-485" name="ln-485" href="#ln-485"></a><span class="k"> do while</span><span class="p">(</span><span class="nb">associated</span><span class="p">(</span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">cache</span><span class="p">))</span>
<a id="ln-486" name="ln-486" href="#ln-486"></a><span class="w"> </span><span class="n">map_entry_pool_head</span><span class="w"> </span><span class="o">=></span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">cache</span>
<a id="ln-487" name="ln-487" href="#ln-487"></a><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">cache</span><span class="w"> </span><span class="o">=></span><span class="w"> </span><span class="n">map_entry_pool_head</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">lastpool</span>
<a id="ln-488" name="ln-488" href="#ln-488"></a><span class="w"> </span><span class="n">map_entry_pool_head</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">lastpool</span><span class="w"> </span><span class="o">=></span><span class="w"> </span><span class="nb">null</span><span class="p">()</span>
<a id="ln-489" name="ln-489" href="#ln-489"></a><span class="w"> </span><span class="k">deallocate</span><span class="p">(</span><span class="w"> </span><span class="n">map_entry_pool_head</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">more_map_entries</span><span class="w"> </span><span class="p">)</span>
<a id="ln-490" name="ln-490" href="#ln-490"></a><span class="w"> </span><span class="k">deallocate</span><span class="p">(</span><span class="w"> </span><span class="n">map_entry_pool_head</span><span class="w"> </span><span class="p">)</span>
<a id="ln-491" name="ln-491" href="#ln-491"></a><span class="w"> </span><span class="k">end do</span>
<a id="ln-492" name="ln-492" href="#ln-492"></a>
<a id="ln-493" name="ln-493" href="#ln-493"></a><span class="k"> call </span><span class="n">extend_map_entry_pool</span><span class="p">(</span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">cache</span><span class="p">)</span>
<a id="ln-494" name="ln-494" href="#ln-494"></a>
<a id="ln-495" name="ln-495" href="#ln-495"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nb">present</span><span class="p">(</span><span class="n">status</span><span class="p">)</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="n">status</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">success</span>
<a id="ln-496" name="ln-496" href="#ln-496"></a>
<a id="ln-497" name="ln-497" href="#ln-497"></a><span class="w"> </span><span class="k">end subroutine </span><span class="n">init_open_map</span>
<a id="ln-498" name="ln-498" href="#ln-498"></a>
<a id="ln-499" name="ln-499" href="#ln-499"></a>
<a id="ln-500" name="ln-500" href="#ln-500"></a><span class="w"> </span><span class="k">pure module function </span><span class="n">open_loading</span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">)</span>
<a id="ln-501" name="ln-501" href="#ln-501"></a><span class="c">!! Version: Experimental</span>
<a id="ln-502" name="ln-502" href="#ln-502"></a><span class="c">!!</span>
<a id="ln-503" name="ln-503" href="#ln-503"></a><span class="c">!! Returns the number of entries relative to slots in a hash map</span>
<a id="ln-504" name="ln-504" href="#ln-504"></a><span class="c">!! Arguments:</span>
<a id="ln-505" name="ln-505" href="#ln-505"></a><span class="c">!! map - an open hash map</span>
<a id="ln-506" name="ln-506" href="#ln-506"></a><span class="w"> </span><span class="k">class</span><span class="p">(</span><span class="n">open_hashmap_type</span><span class="p">),</span><span class="w"> </span><span class="k">intent</span><span class="p">(</span><span class="n">in</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">map</span>
<a id="ln-507" name="ln-507" href="#ln-507"></a><span class="w"> </span><span class="kt">real</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">open_loading</span>
<a id="ln-508" name="ln-508" href="#ln-508"></a>
<a id="ln-509" name="ln-509" href="#ln-509"></a><span class="w"> </span><span class="n">open_loading</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kt">real</span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">num_entries</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="p">&</span>
<a id="ln-510" name="ln-510" href="#ln-510"></a><span class="w"> </span><span class="n">size</span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">slots</span><span class="p">,</span><span class="w"> </span><span class="nb">kind</span><span class="o">=</span><span class="n">int_index</span><span class="w"> </span><span class="p">)</span>
<a id="ln-511" name="ln-511" href="#ln-511"></a>
<a id="ln-512" name="ln-512" href="#ln-512"></a><span class="w"> </span><span class="k">end function </span><span class="n">open_loading</span>
<a id="ln-513" name="ln-513" href="#ln-513"></a>
<a id="ln-514" name="ln-514" href="#ln-514"></a>
<a id="ln-515" name="ln-515" href="#ln-515"></a><span class="w"> </span><span class="k">module subroutine </span><span class="n">map_open_entry</span><span class="p">(</span><span class="n">map</span><span class="p">,</span><span class="w"> </span><span class="n">key</span><span class="p">,</span><span class="w"> </span><span class="n">other</span><span class="p">,</span><span class="w"> </span><span class="n">conflict</span><span class="p">)</span>
<a id="ln-516" name="ln-516" href="#ln-516"></a><span class="c">!! Version: Experimental</span>
<a id="ln-517" name="ln-517" href="#ln-517"></a><span class="c">!!</span>
<a id="ln-518" name="ln-518" href="#ln-518"></a><span class="c">!! Inserts an entry into the hash table</span>
<a id="ln-519" name="ln-519" href="#ln-519"></a><span class="c">!! Arguments:</span>
<a id="ln-520" name="ln-520" href="#ln-520"></a><span class="c">!! map the hash table of interest</span>
<a id="ln-521" name="ln-521" href="#ln-521"></a><span class="c">!! key - the key identifying the entry</span>
<a id="ln-522" name="ln-522" href="#ln-522"></a><span class="c">!! other - other data associated with the key</span>
<a id="ln-523" name="ln-523" href="#ln-523"></a><span class="c">!! conflict - logical flag indicating whether the entry key conflicts</span>
<a id="ln-524" name="ln-524" href="#ln-524"></a><span class="c">!! with an existing key</span>
<a id="ln-525" name="ln-525" href="#ln-525"></a><span class="c">!</span>
<a id="ln-526" name="ln-526" href="#ln-526"></a><span class="w"> </span><span class="k">class</span><span class="p">(</span><span class="n">open_hashmap_type</span><span class="p">),</span><span class="w"> </span><span class="k">intent</span><span class="p">(</span><span class="n">inout</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">map</span>
<a id="ln-527" name="ln-527" href="#ln-527"></a><span class="w"> </span><span class="k">type</span><span class="p">(</span><span class="n">key_type</span><span class="p">),</span><span class="w"> </span><span class="k">intent</span><span class="p">(</span><span class="n">in</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">key</span>
<a id="ln-528" name="ln-528" href="#ln-528"></a><span class="w"> </span><span class="k">class</span><span class="p">(</span><span class="o">*</span><span class="p">),</span><span class="w"> </span><span class="k">intent</span><span class="p">(</span><span class="n">in</span><span class="p">),</span><span class="w"> </span><span class="k">optional</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">other</span>
<a id="ln-529" name="ln-529" href="#ln-529"></a><span class="w"> </span><span class="kt">logical</span><span class="p">,</span><span class="w"> </span><span class="k">intent</span><span class="p">(</span><span class="n">out</span><span class="p">),</span><span class="w"> </span><span class="k">optional</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">conflict</span>
<a id="ln-530" name="ln-530" href="#ln-530"></a>
<a id="ln-531" name="ln-531" href="#ln-531"></a><span class="w"> </span><span class="k">type</span><span class="p">(</span><span class="n">open_map_entry_type</span><span class="p">),</span><span class="w"> </span><span class="k">pointer</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">new_ent</span>
<a id="ln-532" name="ln-532" href="#ln-532"></a><span class="w"> </span><span class="kt">integer</span><span class="p">(</span><span class="n">int_hash</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">base_slot</span>
<a id="ln-533" name="ln-533" href="#ln-533"></a><span class="w"> </span><span class="kt">integer</span><span class="p">(</span><span class="n">int_hash</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">hash_val</span>
<a id="ln-534" name="ln-534" href="#ln-534"></a><span class="w"> </span><span class="kt">integer</span><span class="p">(</span><span class="n">int_index</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">inmap</span><span class="p">,</span><span class="w"> </span><span class="n">offset</span><span class="p">,</span><span class="w"> </span><span class="n">test_slot</span>
<a id="ln-535" name="ln-535" href="#ln-535"></a><span class="w"> </span><span class="kt">character</span><span class="p">(</span><span class="o">*</span><span class="p">),</span><span class="w"> </span><span class="k">parameter</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="k">procedure</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'MAP_ENTRY'</span>
<a id="ln-536" name="ln-536" href="#ln-536"></a>
<a id="ln-537" name="ln-537" href="#ln-537"></a><span class="w"> </span><span class="n">hash_val</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">hasher</span><span class="p">(</span><span class="w"> </span><span class="n">key</span><span class="w"> </span><span class="p">)</span>
<a id="ln-538" name="ln-538" href="#ln-538"></a>
<a id="ln-539" name="ln-539" href="#ln-539"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">probe_count</span><span class="w"> </span><span class="o">></span><span class="w"> </span><span class="n">map_probe_factor</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">call_count</span><span class="w"> </span><span class="p">.</span><span class="nb">or</span><span class="p">.</span><span class="w"> </span><span class="p">&</span>
<a id="ln-540" name="ln-540" href="#ln-540"></a><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">num_entries</span><span class="w"> </span><span class="o">>=</span><span class="w"> </span><span class="n">load_factor</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="n">size</span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">slots</span><span class="p">,</span><span class="w"> </span><span class="p">&</span>
<a id="ln-541" name="ln-541" href="#ln-541"></a><span class="w"> </span><span class="nb">kind</span><span class="o">=</span><span class="n">int_index</span><span class="p">)</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
<a id="ln-542" name="ln-542" href="#ln-542"></a><span class="k"> call </span><span class="n">expand_slots</span><span class="p">(</span><span class="n">map</span><span class="p">)</span>
<a id="ln-543" name="ln-543" href="#ln-543"></a><span class="w"> </span><span class="k">end if</span>
<a id="ln-544" name="ln-544" href="#ln-544"></a><span class="k"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">call_count</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">call_count</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span>
<a id="ln-545" name="ln-545" href="#ln-545"></a><span class="w"> </span><span class="n">base_slot</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fibonacci_hash</span><span class="p">(</span><span class="w"> </span><span class="n">hash_val</span><span class="p">,</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">nbits</span><span class="w"> </span><span class="p">)</span>
<a id="ln-546" name="ln-546" href="#ln-546"></a>
<a id="ln-547" name="ln-547" href="#ln-547"></a><span class="w"> </span><span class="n">offset</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span>
<a id="ln-548" name="ln-548" href="#ln-548"></a><span class="w"> </span><span class="n">PROBE_SUCCESSIVE_SLOTS</span><span class="p">:</span><span class="w"> </span><span class="k">do</span>
<a id="ln-549" name="ln-549" href="#ln-549"></a><span class="k"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">probe_count</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">probe_count</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span>
<a id="ln-550" name="ln-550" href="#ln-550"></a><span class="w"> </span><span class="n">test_slot</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">iand</span><span class="p">(</span><span class="w"> </span><span class="n">base_slot</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">offset</span><span class="p">,</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">index_mask</span><span class="w"> </span><span class="p">)</span>
<a id="ln-551" name="ln-551" href="#ln-551"></a><span class="w"> </span><span class="n">inmap</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">slots</span><span class="p">(</span><span class="n">test_slot</span><span class="p">)</span>
<a id="ln-552" name="ln-552" href="#ln-552"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="n">inmap</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
<a id="ln-553" name="ln-553" href="#ln-553"></a><span class="k"> call </span><span class="n">allocate_open_map_entry</span><span class="p">(</span><span class="n">map</span><span class="p">,</span><span class="w"> </span><span class="n">new_ent</span><span class="p">)</span>
<a id="ln-554" name="ln-554" href="#ln-554"></a><span class="w"> </span><span class="n">new_ent</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">hash_val</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">hash_val</span>
<a id="ln-555" name="ln-555" href="#ln-555"></a><span class="w"> </span><span class="k">call </span><span class="n">copy_key</span><span class="p">(</span><span class="w"> </span><span class="n">key</span><span class="p">,</span><span class="w"> </span><span class="n">new_ent</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">key</span><span class="w"> </span><span class="p">)</span>
<a id="ln-556" name="ln-556" href="#ln-556"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="nb">present</span><span class="p">(</span><span class="w"> </span><span class="n">other</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="n">new_ent</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">other</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">other</span>
<a id="ln-557" name="ln-557" href="#ln-557"></a><span class="w"> </span><span class="n">inmap</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">new_ent</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">inmap</span>
<a id="ln-558" name="ln-558" href="#ln-558"></a><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">inverse</span><span class="p">(</span><span class="w"> </span><span class="n">inmap</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="k">target</span><span class="w"> </span><span class="o">=></span><span class="w"> </span><span class="n">new_ent</span>
<a id="ln-559" name="ln-559" href="#ln-559"></a><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">slots</span><span class="p">(</span><span class="w"> </span><span class="n">test_slot</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">inmap</span>
<a id="ln-560" name="ln-560" href="#ln-560"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="nb">present</span><span class="p">(</span><span class="n">conflict</span><span class="p">)</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="n">conflict</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">.</span><span class="n">false</span><span class="p">.</span>
<a id="ln-561" name="ln-561" href="#ln-561"></a><span class="w"> </span><span class="k">return</span>
<a id="ln-562" name="ln-562" href="#ln-562"></a><span class="k"> else if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="n">inmap</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="p">.</span><span class="nb">or</span><span class="p">.</span><span class="w"> </span><span class="p">&</span>
<a id="ln-563" name="ln-563" href="#ln-563"></a><span class="w"> </span><span class="n">inmap</span><span class="w"> </span><span class="o">></span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">num_entries</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">num_free</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
<a id="ln-564" name="ln-564" href="#ln-564"></a><span class="k"> error stop </span><span class="n">submodule_name</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="s1">' % '</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="k">procedure</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="s1">': '</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="p">&</span>
<a id="ln-565" name="ln-565" href="#ln-565"></a><span class="w"> </span><span class="n">invalid_inmap</span>
<a id="ln-566" name="ln-566" href="#ln-566"></a><span class="w"> </span><span class="k">else if</span><span class="w"> </span><span class="p">(.</span><span class="nb">not</span><span class="p">.</span><span class="w"> </span><span class="nb">associated</span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">inverse</span><span class="p">(</span><span class="n">inmap</span><span class="p">)</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="k">target</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
<a id="ln-567" name="ln-567" href="#ln-567"></a><span class="k"> error stop </span><span class="n">submodule_name</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="s1">' % '</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="k">procedure</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="s1">': '</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="p">&</span>
<a id="ln-568" name="ln-568" href="#ln-568"></a><span class="w"> </span><span class="n">invalid_inmap</span>
<a id="ln-569" name="ln-569" href="#ln-569"></a><span class="w"> </span><span class="k">else</span>
<a id="ln-570" name="ln-570" href="#ln-570"></a><span class="k"> associate</span><span class="p">(</span><span class="w"> </span><span class="k">target</span><span class="w"> </span><span class="o">=></span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">inverse</span><span class="p">(</span><span class="n">inmap</span><span class="p">)</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="k">target</span><span class="w"> </span><span class="p">)</span>
<a id="ln-571" name="ln-571" href="#ln-571"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="n">hash_val</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="k">target</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">hash_val</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
<a id="ln-572" name="ln-572" href="#ln-572"></a><span class="k"> if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="n">key</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="k">target</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">key</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
<a id="ln-573" name="ln-573" href="#ln-573"></a><span class="w"> </span><span class="c">! entry already exists</span>
<a id="ln-574" name="ln-574" href="#ln-574"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="nb">present</span><span class="p">(</span><span class="n">conflict</span><span class="p">)</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
<a id="ln-575" name="ln-575" href="#ln-575"></a><span class="k"> </span><span class="n">conflict</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">.</span><span class="n">true</span><span class="p">.</span>
<a id="ln-576" name="ln-576" href="#ln-576"></a><span class="w"> </span><span class="k">else</span>
<a id="ln-577" name="ln-577" href="#ln-577"></a><span class="k"> error stop </span><span class="n">submodule_name</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="s1">' % '</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="k">procedure</span><span class="w"> </span><span class="p">&</span>
<a id="ln-578" name="ln-578" href="#ln-578"></a><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="s1">': '</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="n">conflicting_key</span>
<a id="ln-579" name="ln-579" href="#ln-579"></a><span class="w"> </span><span class="k">end if</span>
<a id="ln-580" name="ln-580" href="#ln-580"></a><span class="k"> return</span>
<a id="ln-581" name="ln-581" href="#ln-581"></a><span class="k"> end if</span>
<a id="ln-582" name="ln-582" href="#ln-582"></a><span class="k"> end if</span>
<a id="ln-583" name="ln-583" href="#ln-583"></a><span class="k"> end associate</span>
<a id="ln-584" name="ln-584" href="#ln-584"></a><span class="k"> end if</span>
<a id="ln-585" name="ln-585" href="#ln-585"></a><span class="k"> </span><span class="n">offset</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">offset</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span>
<a id="ln-586" name="ln-586" href="#ln-586"></a><span class="w"> </span><span class="k">end do </span><span class="n">PROBE_SUCCESSIVE_SLOTS</span>
<a id="ln-587" name="ln-587" href="#ln-587"></a>
<a id="ln-588" name="ln-588" href="#ln-588"></a><span class="w"> </span><span class="k">contains</span>
<a id="ln-589" name="ln-589" href="#ln-589"></a>
<a id="ln-590" name="ln-590" href="#ln-590"></a><span class="k"> subroutine </span><span class="n">allocate_open_map_entry</span><span class="p">(</span><span class="n">map</span><span class="p">,</span><span class="w"> </span><span class="n">bucket</span><span class="p">)</span>
<a id="ln-591" name="ln-591" href="#ln-591"></a><span class="c">! allocates a hash bucket</span>
<a id="ln-592" name="ln-592" href="#ln-592"></a><span class="w"> </span><span class="k">type</span><span class="p">(</span><span class="n">open_hashmap_type</span><span class="p">),</span><span class="w"> </span><span class="k">intent</span><span class="p">(</span><span class="n">inout</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">map</span>
<a id="ln-593" name="ln-593" href="#ln-593"></a><span class="w"> </span><span class="k">type</span><span class="p">(</span><span class="n">open_map_entry_type</span><span class="p">),</span><span class="w"> </span><span class="k">pointer</span><span class="p">,</span><span class="w"> </span><span class="k">intent</span><span class="p">(</span><span class="n">out</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">bucket</span>
<a id="ln-594" name="ln-594" href="#ln-594"></a><span class="w"> </span><span class="k">type</span><span class="p">(</span><span class="n">open_map_entry_list</span><span class="p">),</span><span class="w"> </span><span class="k">pointer</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">free_list</span>
<a id="ln-595" name="ln-595" href="#ln-595"></a><span class="w"> </span><span class="k">type</span><span class="p">(</span><span class="n">open_map_entry_pool</span><span class="p">),</span><span class="w"> </span><span class="k">pointer</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">pool</span>
<a id="ln-596" name="ln-596" href="#ln-596"></a><span class="w"> </span><span class="kt">character</span><span class="p">(</span><span class="o">*</span><span class="p">),</span><span class="w"> </span><span class="k">parameter</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">procedure_name</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">"ALLOCATE_MAP_ENTRY"</span>
<a id="ln-597" name="ln-597" href="#ln-597"></a>
<a id="ln-598" name="ln-598" href="#ln-598"></a><span class="w"> </span><span class="n">pool</span><span class="w"> </span><span class="o">=></span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">cache</span>
<a id="ln-599" name="ln-599" href="#ln-599"></a><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">num_entries</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">num_entries</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span>
<a id="ln-600" name="ln-600" href="#ln-600"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="nb">associated</span><span class="p">(</span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">free_list</span><span class="p">)</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
<a id="ln-601" name="ln-601" href="#ln-601"></a><span class="c">! Get hash bucket from free_list</span>
<a id="ln-602" name="ln-602" href="#ln-602"></a><span class="w"> </span><span class="n">free_list</span><span class="w"> </span><span class="o">=></span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">free_list</span>
<a id="ln-603" name="ln-603" href="#ln-603"></a><span class="w"> </span><span class="n">bucket</span><span class="w"> </span><span class="o">=></span><span class="w"> </span><span class="n">free_list</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="k">target</span>
<a id="ln-604" name="ln-604" href="#ln-604"></a><span class="k"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">free_list</span><span class="w"> </span><span class="o">=></span><span class="w"> </span><span class="n">free_list</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">next</span>
<a id="ln-605" name="ln-605" href="#ln-605"></a><span class="w"> </span><span class="n">free_list</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="k">target</span><span class="w"> </span><span class="o">=></span><span class="w"> </span><span class="nb">null</span><span class="p">()</span>
<a id="ln-606" name="ln-606" href="#ln-606"></a><span class="w"> </span><span class="n">free_list</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">next</span><span class="w"> </span><span class="o">=></span><span class="w"> </span><span class="nb">null</span><span class="p">()</span>
<a id="ln-607" name="ln-607" href="#ln-607"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">bucket</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">inmap</span><span class="w"> </span><span class="o"><=</span><span class="w"> </span><span class="mi">0</span><span class="p">)</span><span class="w"> </span><span class="p">&</span>
<a id="ln-608" name="ln-608" href="#ln-608"></a><span class="w"> </span><span class="k">error stop </span><span class="n">submodule_name</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="s2">" % "</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="n">procedure_name</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="p">&</span>
<a id="ln-609" name="ln-609" href="#ln-609"></a><span class="w"> </span><span class="s2">": Failed consistency check: BUCKET % INMAP <= 0"</span>
<a id="ln-610" name="ln-610" href="#ln-610"></a><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">num_free</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">num_free</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mi">1</span>
<a id="ln-611" name="ln-611" href="#ln-611"></a><span class="w"> </span><span class="k">else</span>
<a id="ln-612" name="ln-612" href="#ln-612"></a><span class="c">! Get hash bucket from pool</span>
<a id="ln-613" name="ln-613" href="#ln-613"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="n">pool</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">next</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="n">pool_size</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
<a id="ln-614" name="ln-614" href="#ln-614"></a><span class="c">! Expand pool</span>
<a id="ln-615" name="ln-615" href="#ln-615"></a><span class="w"> </span><span class="k">call </span><span class="n">extend_map_entry_pool</span><span class="p">(</span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">cache</span><span class="p">)</span>
<a id="ln-616" name="ln-616" href="#ln-616"></a><span class="w"> </span><span class="n">pool</span><span class="w"> </span><span class="o">=></span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">cache</span>
<a id="ln-617" name="ln-617" href="#ln-617"></a><span class="w"> </span><span class="k">end if</span>
<a id="ln-618" name="ln-618" href="#ln-618"></a><span class="k"> </span><span class="n">bucket</span><span class="w"> </span><span class="o">=></span><span class="w"> </span><span class="n">pool</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">more_map_entries</span><span class="p">(</span><span class="n">pool</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">next</span><span class="p">)</span>
<a id="ln-619" name="ln-619" href="#ln-619"></a><span class="w"> </span><span class="n">pool</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">next</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">pool</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">next</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="c">! 0s based -> post-increment</span>
<a id="ln-620" name="ln-620" href="#ln-620"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">num_entries</span><span class="w"> </span><span class="o">></span><span class="w"> </span><span class="p">&</span>
<a id="ln-621" name="ln-621" href="#ln-621"></a><span class="w"> </span><span class="n">size</span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">inverse</span><span class="p">,</span><span class="w"> </span><span class="nb">kind</span><span class="o">=</span><span class="n">int_index</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
<a id="ln-622" name="ln-622" href="#ln-622"></a><span class="k"> call </span><span class="n">expand_inverse</span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">)</span>
<a id="ln-623" name="ln-623" href="#ln-623"></a><span class="w"> </span><span class="k">end if</span>
<a id="ln-624" name="ln-624" href="#ln-624"></a><span class="k"> if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">num_entries</span><span class="w"> </span><span class="o"><=</span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="p">&</span>
<a id="ln-625" name="ln-625" href="#ln-625"></a><span class="w"> </span><span class="k">error stop </span><span class="n">submodule_name</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="s2">" % "</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="n">procedure_name</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="p">&</span>
<a id="ln-626" name="ln-626" href="#ln-626"></a><span class="w"> </span><span class="s2">": Failed consistency check: MAP % NUM_ENTRIES <= 0."</span>
<a id="ln-627" name="ln-627" href="#ln-627"></a><span class="w"> </span><span class="n">bucket</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">inmap</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">num_entries</span>
<a id="ln-628" name="ln-628" href="#ln-628"></a><span class="w"> </span><span class="k">end if</span>
<a id="ln-629" name="ln-629" href="#ln-629"></a>
<a id="ln-630" name="ln-630" href="#ln-630"></a><span class="k"> end subroutine </span><span class="n">allocate_open_map_entry</span>
<a id="ln-631" name="ln-631" href="#ln-631"></a>
<a id="ln-632" name="ln-632" href="#ln-632"></a><span class="w"> </span><span class="k">subroutine </span><span class="n">expand_inverse</span><span class="p">(</span><span class="n">map</span><span class="p">)</span>
<a id="ln-633" name="ln-633" href="#ln-633"></a><span class="c">!! Increase size of map % inverse</span>
<a id="ln-634" name="ln-634" href="#ln-634"></a><span class="w"> </span><span class="k">type</span><span class="p">(</span><span class="n">open_hashmap_type</span><span class="p">),</span><span class="w"> </span><span class="k">intent</span><span class="p">(</span><span class="n">inout</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">map</span>
<a id="ln-635" name="ln-635" href="#ln-635"></a><span class="w"> </span><span class="k">type</span><span class="p">(</span><span class="n">open_map_entry_ptr</span><span class="p">),</span><span class="w"> </span><span class="k">allocatable</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">dummy_inverse</span><span class="p">(:)</span>
<a id="ln-636" name="ln-636" href="#ln-636"></a>
<a id="ln-637" name="ln-637" href="#ln-637"></a><span class="w"> </span><span class="kt">integer</span><span class="p">(</span><span class="n">int32</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="nb">stat</span>
<a id="ln-638" name="ln-638" href="#ln-638"></a><span class="nb"> </span><span class="kt">character</span><span class="p">(</span><span class="mi">256</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">errmsg</span>
<a id="ln-639" name="ln-639" href="#ln-639"></a>
<a id="ln-640" name="ln-640" href="#ln-640"></a><span class="w"> </span><span class="k">allocate</span><span class="p">(</span><span class="w"> </span><span class="n">dummy_inverse</span><span class="p">(</span><span class="mi">1</span><span class="p">:</span><span class="mi">2</span><span class="o">*</span><span class="n">size</span><span class="p">(</span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">inverse</span><span class="p">,</span><span class="w"> </span><span class="nb">kind</span><span class="o">=</span><span class="n">int_index</span><span class="p">)),</span><span class="w"> </span><span class="p">&</span>
<a id="ln-641" name="ln-641" href="#ln-641"></a><span class="w"> </span><span class="nb">stat</span><span class="o">=</span><span class="nb">stat</span><span class="p">,</span><span class="w"> </span><span class="n">errmsg</span><span class="o">=</span><span class="n">errmsg</span><span class="w"> </span><span class="p">)</span>
<a id="ln-642" name="ln-642" href="#ln-642"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="nb">stat</span><span class="w"> </span><span class="o">/=</span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
<a id="ln-643" name="ln-643" href="#ln-643"></a><span class="k"> write</span><span class="p">(</span><span class="n">error_unit</span><span class="p">,</span><span class="w"> </span><span class="s1">'(a)'</span><span class="p">)</span><span class="w"> </span><span class="s1">'Allocation ERRMSG: '</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="nb">trim</span><span class="p">(</span><span class="n">errmsg</span><span class="p">)</span>
<a id="ln-644" name="ln-644" href="#ln-644"></a><span class="w"> </span><span class="k">error stop </span><span class="n">submodule_name</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="s1">' % '</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="k">procedure</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="s1">': '</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="p">&</span>
<a id="ln-645" name="ln-645" href="#ln-645"></a><span class="w"> </span><span class="n">alloc_inv_fault</span>
<a id="ln-646" name="ln-646" href="#ln-646"></a><span class="w"> </span><span class="k">end if</span>
<a id="ln-647" name="ln-647" href="#ln-647"></a><span class="k"> </span><span class="n">dummy_inverse</span><span class="p">(</span><span class="mi">1</span><span class="p">:</span><span class="n">size</span><span class="p">(</span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">inverse</span><span class="p">,</span><span class="w"> </span><span class="nb">kind</span><span class="o">=</span><span class="n">int_index</span><span class="p">))</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">&</span>
<a id="ln-648" name="ln-648" href="#ln-648"></a><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">inverse</span><span class="p">(:)</span>
<a id="ln-649" name="ln-649" href="#ln-649"></a>
<a id="ln-650" name="ln-650" href="#ln-650"></a><span class="w"> </span><span class="k">call </span><span class="nb">move_alloc</span><span class="p">(</span><span class="w"> </span><span class="n">dummy_inverse</span><span class="p">,</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">inverse</span><span class="w"> </span><span class="p">)</span>
<a id="ln-651" name="ln-651" href="#ln-651"></a>
<a id="ln-652" name="ln-652" href="#ln-652"></a><span class="w"> </span><span class="k">end subroutine </span><span class="n">expand_inverse</span>
<a id="ln-653" name="ln-653" href="#ln-653"></a>
<a id="ln-654" name="ln-654" href="#ln-654"></a><span class="w"> </span><span class="k">end subroutine </span><span class="n">map_open_entry</span>
<a id="ln-655" name="ln-655" href="#ln-655"></a>
<a id="ln-656" name="ln-656" href="#ln-656"></a>
<a id="ln-657" name="ln-657" href="#ln-657"></a><span class="w"> </span><span class="k">module subroutine </span><span class="n">rehash_open_map</span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="p">,</span><span class="w"> </span><span class="n">hasher</span><span class="w"> </span><span class="p">)</span>
<a id="ln-658" name="ln-658" href="#ln-658"></a><span class="c">!! Version: Experimental</span>
<a id="ln-659" name="ln-659" href="#ln-659"></a><span class="c">!!</span>
<a id="ln-660" name="ln-660" href="#ln-660"></a><span class="c">!! Changes the hashing method of the table entries to that of HASHER.</span>
<a id="ln-661" name="ln-661" href="#ln-661"></a><span class="c">!! Arguments:</span>
<a id="ln-662" name="ln-662" href="#ln-662"></a><span class="c">!! map the table to be rehashed</span>
<a id="ln-663" name="ln-663" href="#ln-663"></a><span class="c">!! hasher the hasher function to be used for the table</span>
<a id="ln-664" name="ln-664" href="#ln-664"></a><span class="c">!</span>
<a id="ln-665" name="ln-665" href="#ln-665"></a><span class="w"> </span><span class="k">class</span><span class="p">(</span><span class="n">open_hashmap_type</span><span class="p">),</span><span class="w"> </span><span class="k">intent</span><span class="p">(</span><span class="n">inout</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">map</span>
<a id="ln-666" name="ln-666" href="#ln-666"></a><span class="w"> </span><span class="k">procedure</span><span class="p">(</span><span class="n">hasher_fun</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">hasher</span>
<a id="ln-667" name="ln-667" href="#ln-667"></a>
<a id="ln-668" name="ln-668" href="#ln-668"></a><span class="w"> </span><span class="kt">integer</span><span class="p">(</span><span class="n">int_hash</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">base_slot</span>
<a id="ln-669" name="ln-669" href="#ln-669"></a><span class="w"> </span><span class="kt">integer</span><span class="p">(</span><span class="n">int_hash</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">hash_val</span>
<a id="ln-670" name="ln-670" href="#ln-670"></a><span class="w"> </span><span class="kt">integer</span><span class="p">(</span><span class="n">int_index</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">i</span><span class="p">,</span><span class="w"> </span><span class="n">test_slot</span><span class="p">,</span><span class="w"> </span><span class="n">offset</span>
<a id="ln-671" name="ln-671" href="#ln-671"></a>
<a id="ln-672" name="ln-672" href="#ln-672"></a><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">hasher</span><span class="w"> </span><span class="o">=></span><span class="w"> </span><span class="n">hasher</span>
<a id="ln-673" name="ln-673" href="#ln-673"></a>
<a id="ln-674" name="ln-674" href="#ln-674"></a><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">slots</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span>
<a id="ln-675" name="ln-675" href="#ln-675"></a>
<a id="ln-676" name="ln-676" href="#ln-676"></a><span class="w"> </span><span class="k">do </span><span class="n">i</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">num_entries</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">num_free</span>
<a id="ln-677" name="ln-677" href="#ln-677"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="p">.</span><span class="nb">not</span><span class="p">.</span><span class="w"> </span><span class="nb">associated</span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">inverse</span><span class="p">(</span><span class="n">i</span><span class="p">)</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="k">target</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">cycle</span>
<a id="ln-678" name="ln-678" href="#ln-678"></a><span class="k"> </span><span class="n">hash_val</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">hasher</span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">inverse</span><span class="p">(</span><span class="n">i</span><span class="p">)</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="k">target</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">key</span><span class="w"> </span><span class="p">)</span>
<a id="ln-679" name="ln-679" href="#ln-679"></a><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">inverse</span><span class="p">(</span><span class="n">i</span><span class="p">)</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="k">target</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">hash_val</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">hash_val</span>
<a id="ln-680" name="ln-680" href="#ln-680"></a><span class="w"> </span><span class="n">base_slot</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fibonaccI_hash</span><span class="p">(</span><span class="w"> </span><span class="n">hash_val</span><span class="p">,</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">nbits</span><span class="w"> </span><span class="p">)</span>
<a id="ln-681" name="ln-681" href="#ln-681"></a><span class="w"> </span><span class="n">offset</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span>
<a id="ln-682" name="ln-682" href="#ln-682"></a><span class="w"> </span><span class="n">FIND_EMPTY_SLOT</span><span class="p">:</span><span class="w"> </span><span class="k">do</span>
<a id="ln-683" name="ln-683" href="#ln-683"></a><span class="k"> </span><span class="n">test_slot</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">iand</span><span class="p">(</span><span class="w"> </span><span class="nb">int</span><span class="p">(</span><span class="w"> </span><span class="n">base_slot</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">offset</span><span class="p">,</span><span class="w"> </span><span class="n">int_hash</span><span class="w"> </span><span class="p">),</span><span class="w"> </span><span class="p">&</span>
<a id="ln-684" name="ln-684" href="#ln-684"></a><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">index_mask</span><span class="w"> </span><span class="p">)</span>
<a id="ln-685" name="ln-685" href="#ln-685"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">slots</span><span class="p">(</span><span class="n">test_slot</span><span class="p">)</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
<a id="ln-686" name="ln-686" href="#ln-686"></a><span class="k"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">slots</span><span class="p">(</span><span class="n">test_slot</span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">i</span>
<a id="ln-687" name="ln-687" href="#ln-687"></a><span class="w"> </span><span class="k">exit </span><span class="n">FIND_EMPTY_SLOT</span>
<a id="ln-688" name="ln-688" href="#ln-688"></a><span class="w"> </span><span class="k">end if</span>
<a id="ln-689" name="ln-689" href="#ln-689"></a><span class="k"> </span><span class="n">offset</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">offset</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span>
<a id="ln-690" name="ln-690" href="#ln-690"></a><span class="w"> </span><span class="k">end do </span><span class="n">FIND_EMPTY_SLOT</span>
<a id="ln-691" name="ln-691" href="#ln-691"></a><span class="w"> </span><span class="k">end do</span>
<a id="ln-692" name="ln-692" href="#ln-692"></a>
<a id="ln-693" name="ln-693" href="#ln-693"></a><span class="k"> end subroutine </span><span class="n">rehash_open_map</span>
<a id="ln-694" name="ln-694" href="#ln-694"></a>
<a id="ln-695" name="ln-695" href="#ln-695"></a>
<a id="ln-696" name="ln-696" href="#ln-696"></a><span class="w"> </span><span class="k">module subroutine </span><span class="n">remove_open_entry</span><span class="p">(</span><span class="n">map</span><span class="p">,</span><span class="w"> </span><span class="n">key</span><span class="p">,</span><span class="w"> </span><span class="n">existed</span><span class="p">)</span>
<a id="ln-697" name="ln-697" href="#ln-697"></a><span class="c">!! Remove the entry, if any, that has the key</span>
<a id="ln-698" name="ln-698" href="#ln-698"></a><span class="c">!! Arguments:</span>
<a id="ln-699" name="ln-699" href="#ln-699"></a><span class="c">!! map - the table from which the entry is to be removed</span>
<a id="ln-700" name="ln-700" href="#ln-700"></a><span class="c">!! key - the key to an entry</span>
<a id="ln-701" name="ln-701" href="#ln-701"></a><span class="c">!! existed - a logical flag indicating whether an entry with the key</span>
<a id="ln-702" name="ln-702" href="#ln-702"></a><span class="c">!! was present in the original map</span>
<a id="ln-703" name="ln-703" href="#ln-703"></a><span class="c">!</span>
<a id="ln-704" name="ln-704" href="#ln-704"></a><span class="w"> </span><span class="k">class</span><span class="p">(</span><span class="n">open_hashmap_type</span><span class="p">),</span><span class="w"> </span><span class="k">intent</span><span class="p">(</span><span class="n">inout</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">map</span>
<a id="ln-705" name="ln-705" href="#ln-705"></a><span class="w"> </span><span class="k">type</span><span class="p">(</span><span class="n">key_type</span><span class="p">),</span><span class="w"> </span><span class="k">intent</span><span class="p">(</span><span class="n">in</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">key</span>
<a id="ln-706" name="ln-706" href="#ln-706"></a><span class="w"> </span><span class="kt">logical</span><span class="p">,</span><span class="w"> </span><span class="k">intent</span><span class="p">(</span><span class="n">out</span><span class="p">),</span><span class="w"> </span><span class="k">optional</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">existed</span>
<a id="ln-707" name="ln-707" href="#ln-707"></a>
<a id="ln-708" name="ln-708" href="#ln-708"></a><span class="w"> </span><span class="k">type</span><span class="p">(</span><span class="n">open_map_entry_list</span><span class="p">),</span><span class="w"> </span><span class="k">pointer</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">aentry</span>
<a id="ln-709" name="ln-709" href="#ln-709"></a><span class="w"> </span><span class="k">type</span><span class="p">(</span><span class="n">open_map_entry_type</span><span class="p">),</span><span class="w"> </span><span class="k">pointer</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">bucket</span>
<a id="ln-710" name="ln-710" href="#ln-710"></a><span class="w"> </span><span class="kt">integer</span><span class="p">(</span><span class="n">int_index</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">base_slot</span>
<a id="ln-711" name="ln-711" href="#ln-711"></a><span class="w"> </span><span class="kt">integer</span><span class="p">(</span><span class="n">int_index</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">current_index</span>
<a id="ln-712" name="ln-712" href="#ln-712"></a><span class="w"> </span><span class="kt">integer</span><span class="p">(</span><span class="n">int_index</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">current_slot</span>
<a id="ln-713" name="ln-713" href="#ln-713"></a><span class="w"> </span><span class="kt">integer</span><span class="p">(</span><span class="n">int_index</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">empty_slot</span>
<a id="ln-714" name="ln-714" href="#ln-714"></a><span class="w"> </span><span class="kt">integer</span><span class="p">(</span><span class="n">int_index</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">inmap</span>
<a id="ln-715" name="ln-715" href="#ln-715"></a><span class="w"> </span><span class="kt">logical</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">overlap</span>
<a id="ln-716" name="ln-716" href="#ln-716"></a><span class="w"> </span><span class="kt">integer</span><span class="p">(</span><span class="n">int_index</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">slot_index</span>
<a id="ln-717" name="ln-717" href="#ln-717"></a>
<a id="ln-718" name="ln-718" href="#ln-718"></a><span class="w"> </span><span class="n">overlap</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">.</span><span class="n">false</span><span class="p">.</span>
<a id="ln-719" name="ln-719" href="#ln-719"></a><span class="w"> </span><span class="k">call </span><span class="n">in_open_map</span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="p">,</span><span class="w"> </span><span class="n">inmap</span><span class="p">,</span><span class="w"> </span><span class="n">key</span><span class="w"> </span><span class="p">)</span>
<a id="ln-720" name="ln-720" href="#ln-720"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="n">inmap</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="p">.</span><span class="nb">or</span><span class="p">.</span><span class="w"> </span><span class="n">inmap</span><span class="w"> </span><span class="o">></span><span class="w"> </span><span class="n">size</span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">inverse</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
<a id="ln-721" name="ln-721" href="#ln-721"></a><span class="k"> if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="nb">present</span><span class="p">(</span><span class="w"> </span><span class="n">existed</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="n">existed</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">.</span><span class="n">false</span><span class="p">.</span>
<a id="ln-722" name="ln-722" href="#ln-722"></a><span class="w"> </span><span class="k">return</span>
<a id="ln-723" name="ln-723" href="#ln-723"></a><span class="k"> end if</span>
<a id="ln-724" name="ln-724" href="#ln-724"></a>
<a id="ln-725" name="ln-725" href="#ln-725"></a><span class="k"> </span><span class="n">bucket</span><span class="w"> </span><span class="o">=></span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">inverse</span><span class="p">(</span><span class="n">inmap</span><span class="p">)</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="k">target</span>
<a id="ln-726" name="ln-726" href="#ln-726"></a><span class="k"> if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="nb">associated</span><span class="p">(</span><span class="n">bucket</span><span class="p">)</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
<a id="ln-727" name="ln-727" href="#ln-727"></a><span class="k"> </span><span class="n">base_slot</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fibonacci_hash</span><span class="p">(</span><span class="w"> </span><span class="n">bucket</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">hash_val</span><span class="p">,</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">nbits</span><span class="w"> </span><span class="p">)</span>
<a id="ln-728" name="ln-728" href="#ln-728"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="nb">present</span><span class="p">(</span><span class="n">existed</span><span class="p">)</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="n">existed</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">.</span><span class="n">true</span><span class="p">.</span>
<a id="ln-729" name="ln-729" href="#ln-729"></a><span class="w"> </span><span class="k">else</span>
<a id="ln-730" name="ln-730" href="#ln-730"></a><span class="k"> if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="nb">present</span><span class="p">(</span><span class="w"> </span><span class="n">existed</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="n">existed</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">.</span><span class="n">false</span><span class="p">.</span>
<a id="ln-731" name="ln-731" href="#ln-731"></a><span class="w"> </span><span class="k">return</span>
<a id="ln-732" name="ln-732" href="#ln-732"></a><span class="k"> end if</span>
<a id="ln-733" name="ln-733" href="#ln-733"></a>
<a id="ln-734" name="ln-734" href="#ln-734"></a><span class="c">! Find slot associated with inmap and nullify the pointer</span>
<a id="ln-735" name="ln-735" href="#ln-735"></a><span class="w"> </span><span class="n">current_slot</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">base_slot</span>
<a id="ln-736" name="ln-736" href="#ln-736"></a><span class="w"> </span><span class="n">search_for_inmap</span><span class="p">:</span><span class="w"> </span><span class="k">do</span>
<a id="ln-737" name="ln-737" href="#ln-737"></a><span class="k"> </span><span class="n">slot_index</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">slots</span><span class="p">(</span><span class="n">current_slot</span><span class="p">)</span>
<a id="ln-738" name="ln-738" href="#ln-738"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="n">slot_index</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="n">inmap</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
<a id="ln-739" name="ln-739" href="#ln-739"></a><span class="k"> allocate</span><span class="p">(</span><span class="n">aentry</span><span class="p">)</span>
<a id="ln-740" name="ln-740" href="#ln-740"></a><span class="w"> </span><span class="n">aentry</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="k">target</span><span class="w"> </span><span class="o">=></span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">inverse</span><span class="p">(</span><span class="n">inmap</span><span class="p">)</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="k">target</span>
<a id="ln-741" name="ln-741" href="#ln-741"></a><span class="k"> </span><span class="n">aentry</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">next</span><span class="w"> </span><span class="o">=></span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">free_list</span>
<a id="ln-742" name="ln-742" href="#ln-742"></a><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">free_list</span><span class="w"> </span><span class="o">=></span><span class="w"> </span><span class="n">aentry</span>
<a id="ln-743" name="ln-743" href="#ln-743"></a><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">num_free</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">num_free</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span>
<a id="ln-744" name="ln-744" href="#ln-744"></a><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">slots</span><span class="p">(</span><span class="w"> </span><span class="n">current_slot</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span>
<a id="ln-745" name="ln-745" href="#ln-745"></a><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">inverse</span><span class="p">(</span><span class="n">inmap</span><span class="p">)</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="k">target</span><span class="w"> </span><span class="o">=></span><span class="w"> </span><span class="nb">null</span><span class="p">()</span>
<a id="ln-746" name="ln-746" href="#ln-746"></a><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">num_entries</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">num_entries</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mi">1</span>
<a id="ln-747" name="ln-747" href="#ln-747"></a><span class="w"> </span><span class="n">empty_slot</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">current_slot</span>
<a id="ln-748" name="ln-748" href="#ln-748"></a><span class="w"> </span><span class="n">current_slot</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">iand</span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">index_mask</span><span class="p">,</span><span class="w"> </span><span class="n">current_slot</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="p">)</span>
<a id="ln-749" name="ln-749" href="#ln-749"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">slots</span><span class="p">(</span><span class="n">current_slot</span><span class="p">)</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">return</span>
<a id="ln-750" name="ln-750" href="#ln-750"></a><span class="k"> if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="n">current_slot</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="n">overlap</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">.</span><span class="n">true</span><span class="p">.</span>
<a id="ln-751" name="ln-751" href="#ln-751"></a><span class="w"> </span><span class="k">exit </span><span class="n">search_for_inmap</span>
<a id="ln-752" name="ln-752" href="#ln-752"></a><span class="w"> </span><span class="k">else</span>
<a id="ln-753" name="ln-753" href="#ln-753"></a><span class="k"> if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">slots</span><span class="p">(</span><span class="n">current_slot</span><span class="p">)</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">return</span>
<a id="ln-754" name="ln-754" href="#ln-754"></a><span class="k"> </span><span class="n">current_slot</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">iand</span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">index_mask</span><span class="p">,</span><span class="w"> </span><span class="n">current_slot</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="p">)</span>
<a id="ln-755" name="ln-755" href="#ln-755"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="n">current_slot</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="n">overlap</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">.</span><span class="n">true</span><span class="p">.</span>
<a id="ln-756" name="ln-756" href="#ln-756"></a><span class="w"> </span><span class="k">cycle </span><span class="n">search_for_inmap</span>
<a id="ln-757" name="ln-757" href="#ln-757"></a><span class="w"> </span><span class="k">end if</span>
<a id="ln-758" name="ln-758" href="#ln-758"></a><span class="k"> end do </span><span class="n">search_for_inmap</span>
<a id="ln-759" name="ln-759" href="#ln-759"></a>
<a id="ln-760" name="ln-760" href="#ln-760"></a><span class="c">! Have found slot and stored it in free_list, now may need to iteratively</span>
<a id="ln-761" name="ln-761" href="#ln-761"></a><span class="c">! swap to fill holes. First search backwards to find start of run.</span>
<a id="ln-762" name="ln-762" href="#ln-762"></a><span class="w"> </span><span class="n">find_run_start</span><span class="p">:</span><span class="w"> </span><span class="k">do</span>
<a id="ln-763" name="ln-763" href="#ln-763"></a><span class="k"> </span><span class="n">base_slot</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">iand</span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">index_mask</span><span class="p">,</span><span class="w"> </span><span class="n">base_slot</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="p">)</span>
<a id="ln-764" name="ln-764" href="#ln-764"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="n">base_slot</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">index_mask</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
<a id="ln-765" name="ln-765" href="#ln-765"></a><span class="k"> if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">slots</span><span class="p">(</span><span class="n">base_slot</span><span class="p">)</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
<a id="ln-766" name="ln-766" href="#ln-766"></a><span class="k"> </span><span class="n">base_slot</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span>
<a id="ln-767" name="ln-767" href="#ln-767"></a><span class="w"> </span><span class="k">exit </span><span class="n">find_run_start</span>
<a id="ln-768" name="ln-768" href="#ln-768"></a><span class="w"> </span><span class="k">else</span>
<a id="ln-769" name="ln-769" href="#ln-769"></a><span class="k"> </span><span class="n">overlap</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">.</span><span class="n">true</span><span class="p">.</span>
<a id="ln-770" name="ln-770" href="#ln-770"></a><span class="w"> </span><span class="k">cycle </span><span class="n">find_run_start</span>
<a id="ln-771" name="ln-771" href="#ln-771"></a><span class="w"> </span><span class="k">end if</span>
<a id="ln-772" name="ln-772" href="#ln-772"></a><span class="k"> else if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">slots</span><span class="p">(</span><span class="n">base_slot</span><span class="p">)</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
<a id="ln-773" name="ln-773" href="#ln-773"></a><span class="k"> </span><span class="n">base_slot</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">iand</span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">index_mask</span><span class="p">,</span><span class="w"> </span><span class="n">base_slot</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="p">)</span>
<a id="ln-774" name="ln-774" href="#ln-774"></a><span class="w"> </span><span class="k">exit </span><span class="n">find_run_start</span>
<a id="ln-775" name="ln-775" href="#ln-775"></a><span class="w"> </span><span class="k">else</span>
<a id="ln-776" name="ln-776" href="#ln-776"></a><span class="k"> cycle </span><span class="n">find_run_start</span>
<a id="ln-777" name="ln-777" href="#ln-777"></a><span class="w"> </span><span class="k">end if</span>
<a id="ln-778" name="ln-778" href="#ln-778"></a><span class="k"> end do </span><span class="n">find_run_start</span>
<a id="ln-779" name="ln-779" href="#ln-779"></a>
<a id="ln-780" name="ln-780" href="#ln-780"></a><span class="c">! Search forward for entry to fill empty slot</span>
<a id="ln-781" name="ln-781" href="#ln-781"></a><span class="w"> </span><span class="n">fill_empty_slots</span><span class="p">:</span><span class="w"> </span><span class="k">do</span>
<a id="ln-782" name="ln-782" href="#ln-782"></a><span class="k"> </span><span class="n">bucket</span><span class="w"> </span><span class="o">=></span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">inverse</span><span class="p">(</span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">slots</span><span class="p">(</span><span class="n">current_slot</span><span class="p">)</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="k">target</span>
<a id="ln-783" name="ln-783" href="#ln-783"></a><span class="k"> </span><span class="n">current_index</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fibonacci_hash</span><span class="p">(</span><span class="w"> </span><span class="n">bucket</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">hash_val</span><span class="p">,</span><span class="w"> </span><span class="p">&</span>
<a id="ln-784" name="ln-784" href="#ln-784"></a><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">nbits</span><span class="w"> </span><span class="p">)</span>
<a id="ln-785" name="ln-785" href="#ln-785"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="n">overlap</span><span class="w"> </span><span class="p">.</span><span class="nb">and</span><span class="p">.</span><span class="w"> </span><span class="n">empty_slot</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="n">base_slot</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
<a id="ln-786" name="ln-786" href="#ln-786"></a><span class="k"> if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="n">current_index</span><span class="w"> </span><span class="o">>=</span><span class="w"> </span><span class="n">base_slot</span><span class="w"> </span><span class="p">.</span><span class="nb">and</span><span class="p">.</span><span class="w"> </span><span class="p">&</span>
<a id="ln-787" name="ln-787" href="#ln-787"></a><span class="w"> </span><span class="n">current_index</span><span class="w"> </span><span class="o"><=</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">index_mask</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="p">.</span><span class="nb">or</span><span class="p">.</span><span class="w"> </span><span class="p">&</span>
<a id="ln-788" name="ln-788" href="#ln-788"></a><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="n">current_index</span><span class="w"> </span><span class="o">>=</span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="p">.</span><span class="nb">and</span><span class="p">.</span><span class="w"> </span><span class="p">&</span>
<a id="ln-789" name="ln-789" href="#ln-789"></a><span class="w"> </span><span class="n">current_index</span><span class="w"> </span><span class="o"><=</span><span class="w"> </span><span class="n">empty_slot</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
<a id="ln-790" name="ln-790" href="#ln-790"></a><span class="k"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">slots</span><span class="p">(</span><span class="w"> </span><span class="n">empty_slot</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">slots</span><span class="p">(</span><span class="w"> </span><span class="n">current_slot</span><span class="w"> </span><span class="p">)</span>
<a id="ln-791" name="ln-791" href="#ln-791"></a><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">slots</span><span class="p">(</span><span class="w"> </span><span class="n">current_slot</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span>
<a id="ln-792" name="ln-792" href="#ln-792"></a><span class="w"> </span><span class="n">empty_slot</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">current_slot</span>
<a id="ln-793" name="ln-793" href="#ln-793"></a><span class="w"> </span><span class="k">end if</span>
<a id="ln-794" name="ln-794" href="#ln-794"></a><span class="k"> </span><span class="n">current_slot</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">iand</span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">index_mask</span><span class="p">,</span><span class="w"> </span><span class="n">current_slot</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="p">)</span>
<a id="ln-795" name="ln-795" href="#ln-795"></a><span class="w"> </span><span class="k">else</span>
<a id="ln-796" name="ln-796" href="#ln-796"></a><span class="k"> if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="n">current_index</span><span class="w"> </span><span class="o">>=</span><span class="w"> </span><span class="n">base_slot</span><span class="w"> </span><span class="p">.</span><span class="nb">and</span><span class="p">.</span><span class="w"> </span><span class="p">&</span>
<a id="ln-797" name="ln-797" href="#ln-797"></a><span class="w"> </span><span class="n">current_index</span><span class="w"> </span><span class="o"><=</span><span class="w"> </span><span class="n">empty_slot</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
<a id="ln-798" name="ln-798" href="#ln-798"></a><span class="k"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">slots</span><span class="p">(</span><span class="w"> </span><span class="n">empty_slot</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">slots</span><span class="p">(</span><span class="w"> </span><span class="n">current_slot</span><span class="w"> </span><span class="p">)</span>
<a id="ln-799" name="ln-799" href="#ln-799"></a><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">slots</span><span class="p">(</span><span class="w"> </span><span class="n">current_slot</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span>
<a id="ln-800" name="ln-800" href="#ln-800"></a><span class="w"> </span><span class="n">empty_slot</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">current_slot</span>
<a id="ln-801" name="ln-801" href="#ln-801"></a><span class="w"> </span><span class="k">end if</span>
<a id="ln-802" name="ln-802" href="#ln-802"></a><span class="k"> </span><span class="n">current_slot</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">iand</span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">index_mask</span><span class="p">,</span><span class="w"> </span><span class="n">current_slot</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="p">)</span>
<a id="ln-803" name="ln-803" href="#ln-803"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="n">current_slot</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="n">overlap</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">.</span><span class="n">true</span><span class="p">.</span>
<a id="ln-804" name="ln-804" href="#ln-804"></a><span class="w"> </span><span class="k">end if</span>
<a id="ln-805" name="ln-805" href="#ln-805"></a><span class="k"> if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">slots</span><span class="p">(</span><span class="w"> </span><span class="n">current_slot</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">exit </span><span class="n">fill_empty_slots</span>
<a id="ln-806" name="ln-806" href="#ln-806"></a><span class="w"> </span><span class="k">end do </span><span class="n">fill_empty_slots</span>
<a id="ln-807" name="ln-807" href="#ln-807"></a>
<a id="ln-808" name="ln-808" href="#ln-808"></a><span class="w"> </span><span class="k">end subroutine </span><span class="n">remove_open_entry</span>
<a id="ln-809" name="ln-809" href="#ln-809"></a>
<a id="ln-810" name="ln-810" href="#ln-810"></a>
<a id="ln-811" name="ln-811" href="#ln-811"></a><span class="w"> </span><span class="k">module subroutine </span><span class="n">set_other_open_data</span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="p">,</span><span class="w"> </span><span class="n">key</span><span class="p">,</span><span class="w"> </span><span class="n">other</span><span class="p">,</span><span class="w"> </span><span class="n">exists</span><span class="w"> </span><span class="p">)</span>
<a id="ln-812" name="ln-812" href="#ln-812"></a><span class="c">!! Version: Experimental</span>
<a id="ln-813" name="ln-813" href="#ln-813"></a><span class="c">!!</span>
<a id="ln-814" name="ln-814" href="#ln-814"></a><span class="c">!! Change the other data associated with the key</span>
<a id="ln-815" name="ln-815" href="#ln-815"></a><span class="c">!! Arguments:</span>
<a id="ln-816" name="ln-816" href="#ln-816"></a><span class="c">!! map - the map with the entry of interest</span>
<a id="ln-817" name="ln-817" href="#ln-817"></a><span class="c">!! key - the key to the entry inthe map</span>
<a id="ln-818" name="ln-818" href="#ln-818"></a><span class="c">!! other - the new data to be associated with the key</span>
<a id="ln-819" name="ln-819" href="#ln-819"></a><span class="c">!! exists - a logical flag indicating whether the key is already entered</span>
<a id="ln-820" name="ln-820" href="#ln-820"></a><span class="c">!! in the map</span>
<a id="ln-821" name="ln-821" href="#ln-821"></a><span class="c">!</span>
<a id="ln-822" name="ln-822" href="#ln-822"></a><span class="w"> </span><span class="k">class</span><span class="p">(</span><span class="n">open_hashmap_type</span><span class="p">),</span><span class="w"> </span><span class="k">intent</span><span class="p">(</span><span class="n">inout</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">map</span>
<a id="ln-823" name="ln-823" href="#ln-823"></a><span class="w"> </span><span class="k">type</span><span class="p">(</span><span class="n">key_type</span><span class="p">),</span><span class="w"> </span><span class="k">intent</span><span class="p">(</span><span class="n">in</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">key</span>
<a id="ln-824" name="ln-824" href="#ln-824"></a><span class="w"> </span><span class="k">class</span><span class="p">(</span><span class="o">*</span><span class="p">),</span><span class="w"> </span><span class="k">intent</span><span class="p">(</span><span class="n">in</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">other</span>
<a id="ln-825" name="ln-825" href="#ln-825"></a><span class="w"> </span><span class="kt">logical</span><span class="p">,</span><span class="w"> </span><span class="k">intent</span><span class="p">(</span><span class="n">out</span><span class="p">),</span><span class="k">optional</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">exists</span>
<a id="ln-826" name="ln-826" href="#ln-826"></a>
<a id="ln-827" name="ln-827" href="#ln-827"></a><span class="w"> </span><span class="kt">integer</span><span class="p">(</span><span class="n">int_index</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">inmap</span>
<a id="ln-828" name="ln-828" href="#ln-828"></a>
<a id="ln-829" name="ln-829" href="#ln-829"></a><span class="w"> </span><span class="kt">character</span><span class="p">(</span><span class="o">*</span><span class="p">),</span><span class="w"> </span><span class="k">parameter</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="k">procedure</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'SET_OTHER_DATA'</span>
<a id="ln-830" name="ln-830" href="#ln-830"></a>
<a id="ln-831" name="ln-831" href="#ln-831"></a><span class="w"> </span><span class="k">call </span><span class="n">in_open_map</span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="p">,</span><span class="w"> </span><span class="n">inmap</span><span class="p">,</span><span class="w"> </span><span class="n">key</span><span class="w"> </span><span class="p">)</span>
<a id="ln-832" name="ln-832" href="#ln-832"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="n">inmap</span><span class="w"> </span><span class="o"><=</span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="p">.</span><span class="nb">or</span><span class="p">.</span><span class="w"> </span><span class="n">inmap</span><span class="w"> </span><span class="o">></span><span class="w"> </span><span class="n">size</span><span class="p">(</span><span class="w"> </span><span class="n">map</span><span class="w"> </span><span class="p">%</span><span class="w"> </span><span class="n">inverse</span><span class="p">,</span><span class="w"> </span><span class="nb">kind</span><span class="o">=</span><span class="n">int_index</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="p">&</span>
<a id="ln-833" name="ln-833" href="#ln-833"></a><span class="w"> </span><span class="k">then</span>
<a id="ln-834" name="ln-834" href="#ln-834"></a><span class="k"> if</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="nb">present</span><span class="p">(</span><span class="n">exists</span><span class="p">)</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
<a id="ln-835" name="ln-835" href="#ln-835"></a><span class="k"> </span><span class="n">exists</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">.</span><span class="n">false</span><span class="p">.</span>
<a id="ln-836" name="ln-836" href="#ln-836"></a><span class="w"> </span><span class="k">return</span>
<a id="ln-837" name="ln-837" href="#ln-837"></a><span class="k"> else</span>
<a id="ln-838" name="ln-838" href="#ln-838"></a><span class="k"> error stop </span><span class="n">submodule_name</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="s1">' % '</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="k">procedure</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="s1">': '</span><span class="w"> </span><span class="o">//</span><span class="w"> </span><span class="p">&</span>
<a id="ln-839" name="ln-839" href="#ln-839"></a><span class="w"> </span><span class="n">invalid_inmap</span>