1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- G N A T . T A B L E --
9 -- Copyright (C) 1998-2017, AdaCore --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. --
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
19 -- additional permissions described in the GCC Runtime Library Exception, --
20 -- version 3.1, as published by the Free Software Foundation. --
22 -- You should have received a copy of the GNU General Public License and --
23 -- a copy of the GCC Runtime Library Exception along with this program; --
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
25 -- <http://www.gnu.org/licenses/>. --
27 -- GNAT was originally developed by the GNAT team at New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
30 ------------------------------------------------------------------------------
32 -- This package provides a singleton version of GNAT.Dynamic_Tables
33 -- (g-dyntab.ads). See that package for documentation. This package just
34 -- declares a single instance of GNAT.Dynamic_Tables.Instance, and provides
35 -- wrappers for all the subprograms, passing that single instance.
37 -- Note that these three interfaces should remain synchronized to keep as much
38 -- coherency as possible among these related units:
40 -- GNAT.Dynamic_Tables
42 -- Table (the compiler unit)
44 with GNAT
.Dynamic_Tables
;
47 type Table_Component_Type
is private;
48 type Table_Index_Type
is range <>;
50 Table_Low_Bound
: Table_Index_Type
:= Table_Index_Type
'First;
51 Table_Initial
: Positive := 8;
52 Table_Increment
: Natural := 100;
53 Table_Name
: String := ""; -- for debugging printouts
54 pragma Unreferenced
(Table_Name
);
55 Release_Threshold
: Natural := 0;
58 pragma Elaborate_Body
;
60 package Tab
is new GNAT
.Dynamic_Tables
61 (Table_Component_Type
,
68 subtype Valid_Table_Index_Type
is Tab
.Valid_Table_Index_Type
;
69 subtype Table_Last_Type
is Tab
.Table_Last_Type
;
70 subtype Table_Type
is Tab
.Table_Type
;
71 function "=" (X
, Y
: Table_Type
) return Boolean renames Tab
."=";
73 subtype Table_Ptr
is Tab
.Table_Ptr
;
75 The_Instance
: Tab
.Instance
;
76 Table
: Table_Ptr
renames The_Instance
.Table
;
77 Locked
: Boolean renames The_Instance
.Locked
;
79 function Is_Empty
return Boolean;
86 function First
return Table_Index_Type
;
87 pragma Inline
(First
);
89 function Last
return Table_Last_Type
;
93 pragma Inline
(Release
);
95 procedure Set_Last
(New_Val
: Table_Last_Type
);
96 pragma Inline
(Set_Last
);
98 procedure Increment_Last
;
99 pragma Inline
(Increment_Last
);
101 procedure Decrement_Last
;
102 pragma Inline
(Decrement_Last
);
104 procedure Append
(New_Val
: Table_Component_Type
);
105 pragma Inline
(Append
);
107 procedure Append_All
(New_Vals
: Table_Type
);
108 pragma Inline
(Append_All
);
111 (Index
: Valid_Table_Index_Type
;
112 Item
: Table_Component_Type
);
113 pragma Inline
(Set_Item
);
115 subtype Saved_Table
is Tab
.Instance
;
116 -- Type used for Save/Restore subprograms
118 function Save
return Saved_Table
;
119 pragma Inline
(Save
);
120 -- Resets table to empty, but saves old contents of table in returned
121 -- value, for possible later restoration by a call to Restore.
123 procedure Restore
(T
: in out Saved_Table
);
124 pragma Inline
(Restore
);
125 -- Given a Saved_Table value returned by a prior call to Save, restores
126 -- the table to the state it was in at the time of the Save call.
128 procedure Allocate
(Num
: Integer := 1);
129 function Allocate
(Num
: Integer := 1) return Valid_Table_Index_Type
;
130 pragma Inline
(Allocate
);
131 -- Adds Num to Last. The function version also returns the old value of
132 -- Last + 1. Note that this function has the possible side effect of
133 -- reallocating the table. This means that a reference X.Table (X.Allocate)
134 -- is incorrect, since the call to X.Allocate may modify the results of
138 with procedure Action
139 (Index
: Valid_Table_Index_Type
;
140 Item
: Table_Component_Type
;
141 Quit
: in out Boolean) is <>;
143 pragma Inline
(For_Each
);
146 with function Lt
(Comp1
, Comp2
: Table_Component_Type
) return Boolean;
147 procedure Sort_Table
;
148 pragma Inline
(Sort_Table
);