14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
package body Natools.Smaz is
use type Ada.Streams.Stream_Element_Offset;
function Dict_Entry
(Dict : in Dictionary;
Index : in Ada.Streams.Stream_Element)
return String
with Pre => Index <= Dict.Dict_Last;
-- Return the string for at the given Index in Dict
procedure Find_Entry
(Dict : in Dictionary;
Template : in String;
Index : out Ada.Streams.Stream_Element;
Length : out Natural);
-- Try to find the longest entry in Dict that is a prefix of Template,
|
<
<
<
<
<
<
|
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
package body Natools.Smaz is
use type Ada.Streams.Stream_Element_Offset;
procedure Find_Entry
(Dict : in Dictionary;
Template : in String;
Index : out Ada.Streams.Stream_Element;
Length : out Natural);
-- Try to find the longest entry in Dict that is a prefix of Template,
|
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
|
-- Return the number of bytes needed by the verbatim encoding
-- of Original_Size bytes.
------------------------------
-- Local Helper Subprograms --
------------------------------
function Dict_Entry
(Dict : in Dictionary;
Index : in Ada.Streams.Stream_Element)
return String
is
First : constant Positive := Dict.Offsets (Index);
Last : Natural := Dict.Values'Last;
begin
if Index + 1 in Dict.Offsets'Range then
Last := Dict.Offsets (Index + 1) - 1;
end if;
return Dict.Values (First .. Last);
end Dict_Entry;
procedure Find_Entry
(Dict : in Dictionary;
Template : in String;
Index : out Ada.Streams.Stream_Element;
Length : out Natural)
is
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
-- Return the number of bytes needed by the verbatim encoding
-- of Original_Size bytes.
------------------------------
-- Local Helper Subprograms --
------------------------------
procedure Find_Entry
(Dict : in Dictionary;
Template : in String;
Index : out Ada.Streams.Stream_Element;
Length : out Natural)
is
|
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
end Verbatim_Size;
----------------------
-- Public Interface --
----------------------
function Compressed_Upper_Bound
(Dict : in Dictionary;
Input : in String)
return Ada.Streams.Stream_Element_Count is
begin
return Verbatim_Size (Dict, Input'Length);
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
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
|
end Verbatim_Size;
----------------------
-- Public Interface --
----------------------
function Dict_Entry
(Dict : in Dictionary;
Index : in Ada.Streams.Stream_Element)
return String
is
First : constant Positive := Dict.Offsets (Index);
Last : Natural := Dict.Values'Last;
begin
if Index + 1 in Dict.Offsets'Range then
Last := Dict.Offsets (Index + 1) - 1;
end if;
return Dict.Values (First .. Last);
end Dict_Entry;
function Compressed_Upper_Bound
(Dict : in Dictionary;
Input : in String)
return Ada.Streams.Stream_Element_Count is
begin
return Verbatim_Size (Dict, Input'Length);
|