1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- G N A T . T A B L E --
9 -- Copyright (C) 1998-2023, 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 with System
; use System
;
33 with System
.Memory
; use System
.Memory
;
35 package body GNAT
.Table
is
41 procedure Allocate
(Num
: Integer := 1) is
43 Tab
.Allocate
(The_Instance
, Num
);
46 function Allocate
(Num
: Integer := 1) return Valid_Table_Index_Type
is
47 Result
: constant Valid_Table_Index_Type
:= Last
+ 1;
57 procedure Append
(New_Val
: Table_Component_Type
) is
59 Tab
.Append
(The_Instance
, New_Val
);
66 procedure Append_All
(New_Vals
: Table_Type
) is
68 Tab
.Append_All
(The_Instance
, New_Vals
);
75 procedure Decrement_Last
is
77 Tab
.Decrement_Last
(The_Instance
);
84 function First
return Table_Index_Type
is
94 procedure For_Each
is new Tab
.For_Each
(Action
);
96 For_Each
(The_Instance
);
105 Tab
.Free
(The_Instance
);
112 procedure Increment_Last
is
114 Tab
.Increment_Last
(The_Instance
);
121 function Is_Empty
return Boolean is
123 return Tab
.Is_Empty
(The_Instance
);
132 Tab
.Init
(The_Instance
);
139 function Last
return Table_Last_Type
is
141 return Tab
.Last
(The_Instance
);
150 Tab
.Release
(The_Instance
);
157 procedure Restore
(T
: in out Saved_Table
) is
160 Tab
.Move
(From
=> T
, To
=> The_Instance
);
167 function Save
return Saved_Table
is
168 Result
: Saved_Table
;
170 Tab
.Move
(From
=> The_Instance
, To
=> Result
);
179 (Index
: Valid_Table_Index_Type
;
180 Item
: Table_Component_Type
)
183 Tab
.Set_Item
(The_Instance
, Index
, Item
);
190 procedure Set_Last
(New_Val
: Table_Last_Type
) is
192 Tab
.Set_Last
(The_Instance
, New_Val
);
199 procedure Sort_Table
is
200 procedure Sort_Table
is new Tab
.Sort_Table
(Lt
);
202 Sort_Table
(The_Instance
);