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
|
end Image;
----------------------
-- Public Interface --
----------------------
function Linear_Search (Value : String) return Natural is
Result : Ada.Streams.Stream_Element := 0;
begin
for S of List_For_Linear_Search loop
exit when S = Value;
Result := Result + 1;
end loop;
return Natural (Result);
end Linear_Search;
procedure Print_Dictionary_In_Ada
(Dict : in Dictionary;
Hash_Image : in String := "TODO";
Max_Width : in Positive := 70;
First_Prefix : in String := " := (";
Prefix : in String := " ";
|
<
<
<
<
<
<
<
<
<
<
<
<
|
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
end Image;
----------------------
-- Public Interface --
----------------------
procedure Print_Dictionary_In_Ada
(Dict : in Dictionary;
Hash_Image : in String := "TODO";
Max_Width : in Positive := 70;
First_Prefix : in String := " := (";
Prefix : in String := " ";
|
344
345
346
347
348
349
350
351
352
353
354
355
356
357
|
Max_Word_Length => Max_Word_Length,
Offsets => Offsets,
Values => Values,
Hash => Dummy_Hash'Access);
end;
end To_Dictionary;
-------------------
-- Word Counting --
-------------------
procedure Add_Substrings
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
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
|
Max_Word_Length => Max_Word_Length,
Offsets => Offsets,
Values => Values,
Hash => Dummy_Hash'Access);
end;
end To_Dictionary;
---------------------------------
-- Dynamic Dictionary Searches --
---------------------------------
function Linear_Search (Value : String) return Natural is
Result : Ada.Streams.Stream_Element := 0;
begin
for S of List_For_Linear_Search loop
exit when S = Value;
Result := Result + 1;
end loop;
return Natural (Result);
end Linear_Search;
function Map_Search (Value : String) return Natural is
Cursor : constant Dictionary_Maps.Cursor
:= Dictionary_Maps.Find (Search_Map, Value);
begin
if Dictionary_Maps.Has_Element (Cursor) then
return Natural (Dictionary_Maps.Element (Cursor));
else
return Natural (Ada.Streams.Stream_Element'Last);
end if;
end Map_Search;
procedure Set_Dictionary_For_Map_Search (Dict : in Dictionary) is
begin
Dictionary_Maps.Clear (Search_Map);
for I in Dict.Offsets'Range loop
Dictionary_Maps.Insert (Search_Map, Dict_Entry (Dict, I), I);
end loop;
end Set_Dictionary_For_Map_Search;
-------------------
-- Word Counting --
-------------------
procedure Add_Substrings
|