OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [gcc/] [ada/] [a-coinve.ads] - Blame information for rev 20

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 jlechner
------------------------------------------------------------------------------
2
--                                                                          --
3
--                         GNAT LIBRARY COMPONENTS                          --
4
--                                                                          --
5
--    A D A . C O N T A I N E R S . I N D E F I N I T E _ V E C T O R S     --
6
--                                                                          --
7
--                                 S p e c                                  --
8
--                                                                          --
9
--          Copyright (C) 2004-2005, Free Software Foundation, Inc.         --
10
--                                                                          --
11
-- This specification is derived from the Ada Reference Manual for use with --
12
-- GNAT. The copyright notice above, and the license provisions that follow --
13
-- apply solely to the  contents of the part following the private keyword. --
14
--                                                                          --
15
-- GNAT is free software;  you can  redistribute it  and/or modify it under --
16
-- terms of the  GNU General Public License as published  by the Free Soft- --
17
-- ware  Foundation;  either version 2,  or (at your option) any later ver- --
18
-- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
19
-- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
20
-- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
21
-- for  more details.  You should have  received  a copy of the GNU General --
22
-- Public License  distributed with GNAT;  see file COPYING.  If not, write --
23
-- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
24
-- Boston, MA 02110-1301, USA.                                              --
25
--                                                                          --
26
-- As a special exception,  if other files  instantiate  generics from this --
27
-- unit, or you link  this unit with other files  to produce an executable, --
28
-- this  unit  does not  by itself cause  the resulting  executable  to  be --
29
-- covered  by the  GNU  General  Public  License.  This exception does not --
30
-- however invalidate  any other reasons why  the executable file  might be --
31
-- covered by the  GNU Public License.                                      --
32
--                                                                          --
33
-- This unit was originally developed by Matthew J Heaney.                  --
34
------------------------------------------------------------------------------
35
 
36
with Ada.Finalization;
37
with Ada.Streams;
38
 
39
generic
40
   type Index_Type is range <>;
41
   type Element_Type (<>) is private;
42
 
43
   with function "=" (Left, Right : Element_Type) return Boolean is <>;
44
 
45
package Ada.Containers.Indefinite_Vectors is
46
   pragma Preelaborate;
47
 
48
   subtype Extended_Index is Index_Type'Base
49
     range Index_Type'First - 1 ..
50
           Index_Type'Min (Index_Type'Base'Last - 1, Index_Type'Last) + 1;
51
 
52
   No_Index : constant Extended_Index := Extended_Index'First;
53
 
54
   type Vector is tagged private;
55
 
56
   type Cursor is private;
57
 
58
   Empty_Vector : constant Vector;
59
 
60
   No_Element : constant Cursor;
61
 
62
   function "=" (Left, Right : Vector) return Boolean;
63
 
64
   function To_Vector (Length : Count_Type) return Vector;
65
 
66
   function To_Vector
67
     (New_Item : Element_Type;
68
      Length   : Count_Type) return Vector;
69
 
70
   function "&" (Left, Right : Vector) return Vector;
71
 
72
   function "&" (Left : Vector; Right : Element_Type) return Vector;
73
 
74
   function "&" (Left : Element_Type; Right : Vector) return Vector;
75
 
76
   function "&" (Left, Right : Element_Type) return Vector;
77
 
78
   function Capacity (Container : Vector) return Count_Type;
79
 
80
   procedure Reserve_Capacity
81
     (Container : in out Vector;
82
      Capacity  : Count_Type);
83
 
84
   function Length (Container : Vector) return Count_Type;
85
 
86
   procedure Set_Length
87
     (Container : in out Vector;
88
      Length    : Count_Type);
89
 
90
   function Is_Empty (Container : Vector) return Boolean;
91
 
92
   procedure Clear (Container : in out Vector);
93
 
94
   function To_Cursor
95
     (Container : Vector;
96
      Index     : Extended_Index) return Cursor;
97
 
98
   function To_Index (Position : Cursor) return Extended_Index;
99
 
100
   function Element
101
     (Container : Vector;
102
      Index     : Index_Type) return Element_Type;
103
 
104
   function Element (Position : Cursor) return Element_Type;
105
 
106
   procedure Replace_Element
107
     (Container : in out Vector;
108
      Index     : Index_Type;
109
      New_Item  : Element_Type);
110
 
111
   procedure Replace_Element
112
     (Container : in out Vector;
113
      Position  : Cursor;
114
      New_Item  : Element_Type);
115
 
116
   procedure Query_Element
117
     (Container : Vector;
118
      Index     : Index_Type;
119
      Process   : not null access procedure (Element : Element_Type));
120
 
121
   procedure Query_Element
122
     (Position : Cursor;
123
      Process  : not null access procedure (Element : Element_Type));
124
 
125
   procedure Update_Element
126
     (Container : in out Vector;
127
      Index     : Index_Type;
128
      Process   : not null access procedure (Element : in out Element_Type));
129
 
130
   procedure Update_Element
131
     (Container : in out Vector;
132
      Position  : Cursor;
133
      Process   : not null access procedure (Element : in out Element_Type));
134
 
135
   procedure Move (Target : in out Vector; Source : in out Vector);
136
 
137
   procedure Insert
138
     (Container : in out Vector;
139
      Before    : Extended_Index;
140
      New_Item  : Vector);
141
 
142
   procedure Insert
143
     (Container : in out Vector;
144
      Before    : Cursor;
145
      New_Item  : Vector);
146
 
147
   procedure Insert
148
     (Container : in out Vector;
149
      Before    : Cursor;
150
      New_Item  : Vector;
151
      Position  : out Cursor);
152
 
153
   procedure Insert
154
     (Container : in out Vector;
155
      Before    : Extended_Index;
156
      New_Item  : Element_Type;
157
      Count     : Count_Type := 1);
158
 
159
   procedure Insert
160
     (Container : in out Vector;
161
      Before    : Cursor;
162
      New_Item  : Element_Type;
163
      Count     : Count_Type := 1);
164
 
165
   procedure Insert
166
     (Container : in out Vector;
167
      Before    : Cursor;
168
      New_Item  : Element_Type;
169
      Position  : out Cursor;
170
      Count     : Count_Type := 1);
171
 
172
   procedure Prepend
173
     (Container : in out Vector;
174
      New_Item  : Vector);
175
 
176
   procedure Prepend
177
     (Container : in out Vector;
178
      New_Item  : Element_Type;
179
      Count     : Count_Type := 1);
180
 
181
   procedure Append
182
     (Container : in out Vector;
183
      New_Item  : Vector);
184
 
185
   procedure Append
186
     (Container : in out Vector;
187
      New_Item  : Element_Type;
188
      Count     : Count_Type := 1);
189
 
190
   procedure Insert_Space
191
     (Container : in out Vector;
192
      Before    : Extended_Index;
193
      Count     : Count_Type := 1);
194
 
195
   procedure Insert_Space
196
     (Container : in out Vector;
197
      Before    : Cursor;
198
      Position  : out Cursor;
199
      Count     : Count_Type := 1);
200
 
201
   procedure Delete
202
     (Container : in out Vector;
203
      Index     : Extended_Index;
204
      Count     : Count_Type := 1);
205
 
206
   procedure Delete
207
     (Container : in out Vector;
208
      Position  : in out Cursor;
209
      Count     : Count_Type := 1);
210
 
211
   procedure Delete_First
212
     (Container : in out Vector;
213
      Count     : Count_Type := 1);
214
 
215
   procedure Delete_Last
216
     (Container : in out Vector;
217
      Count     : Count_Type := 1);
218
 
219
   procedure Reverse_Elements (Container : in out Vector);
220
 
221
   procedure Swap (Container : in out Vector; I, J : Index_Type);
222
 
223
   procedure Swap (Container : in out Vector; I, J : Cursor);
224
 
225
   function First_Index (Container : Vector) return Index_Type;
226
 
227
   function First (Container : Vector) return Cursor;
228
 
229
   function First_Element (Container : Vector) return Element_Type;
230
 
231
   function Last_Index (Container : Vector) return Extended_Index;
232
 
233
   function Last (Container : Vector) return Cursor;
234
 
235
   function Last_Element (Container : Vector) return Element_Type;
236
 
237
   function Next (Position : Cursor) return Cursor;
238
 
239
   procedure Next (Position : in out Cursor);
240
 
241
   function Previous (Position : Cursor) return Cursor;
242
 
243
   procedure Previous (Position : in out Cursor);
244
 
245
   function Find_Index
246
     (Container : Vector;
247
      Item      : Element_Type;
248
      Index     : Index_Type := Index_Type'First) return Extended_Index;
249
 
250
   function Find
251
     (Container : Vector;
252
      Item      : Element_Type;
253
      Position  : Cursor := No_Element) return Cursor;
254
 
255
   function Reverse_Find_Index
256
     (Container : Vector;
257
      Item      : Element_Type;
258
      Index     : Index_Type := Index_Type'Last) return Extended_Index;
259
 
260
   function Reverse_Find
261
     (Container : Vector;
262
      Item      : Element_Type;
263
      Position  : Cursor := No_Element) return Cursor;
264
 
265
   function Contains
266
     (Container : Vector;
267
      Item      : Element_Type) return Boolean;
268
 
269
   function Has_Element (Position : Cursor) return Boolean;
270
 
271
   procedure Iterate
272
     (Container : Vector;
273
      Process   : not null access procedure (Position : Cursor));
274
 
275
   procedure Reverse_Iterate
276
     (Container : Vector;
277
      Process   : not null access procedure (Position : Cursor));
278
 
279
   generic
280
      with function "<" (Left, Right : Element_Type) return Boolean is <>;
281
   package Generic_Sorting is
282
 
283
      function Is_Sorted (Container : Vector) return Boolean;
284
 
285
      procedure Sort (Container : in out Vector);
286
 
287
      procedure Merge (Target : in out Vector; Source : in out Vector);
288
 
289
   end Generic_Sorting;
290
 
291
private
292
 
293
   pragma Inline (First_Index);
294
   pragma Inline (Last_Index);
295
   pragma Inline (Element);
296
   pragma Inline (First_Element);
297
   pragma Inline (Last_Element);
298
   pragma Inline (Query_Element);
299
   pragma Inline (Update_Element);
300
   pragma Inline (Replace_Element);
301
   pragma Inline (Contains);
302
 
303
   type Element_Access is access Element_Type;
304
 
305
   type Elements_Type is array (Index_Type range <>) of Element_Access;
306
 
307
   function "=" (L, R : Elements_Type) return Boolean is abstract;
308
 
309
   type Elements_Access is access Elements_Type;
310
 
311
   use Ada.Finalization;
312
 
313
   type Vector is new Controlled with record
314
      Elements : Elements_Access;
315
      Last     : Extended_Index := No_Index;
316
      Busy     : Natural := 0;
317
      Lock     : Natural := 0;
318
   end record;
319
 
320
   procedure Adjust (Container : in out Vector);
321
 
322
   procedure Finalize (Container : in out Vector);
323
 
324
   use Ada.Streams;
325
 
326
   procedure Write
327
     (Stream    : access Root_Stream_Type'Class;
328
      Container : Vector);
329
 
330
   for Vector'Write use Write;
331
 
332
   procedure Read
333
     (Stream    : access Root_Stream_Type'Class;
334
      Container : out Vector);
335
 
336
   for Vector'Read use Read;
337
 
338
   Empty_Vector : constant Vector := (Controlled with null, No_Index, 0, 0);
339
 
340
   type Vector_Access is access constant Vector;
341
   for Vector_Access'Storage_Size use 0;
342
 
343
   type Cursor is record
344
      Container : Vector_Access;
345
      Index     : Index_Type := Index_Type'First;
346
   end record;
347
 
348
   procedure Write
349
     (Stream   : access Root_Stream_Type'Class;
350
      Position : Cursor);
351
 
352
   for Cursor'Write use Write;
353
 
354
   procedure Read
355
     (Stream   : access Root_Stream_Type'Class;
356
      Position : out Cursor);
357
 
358
   for Cursor'Read use Read;
359
 
360
   No_Element : constant Cursor := Cursor'(null, Index_Type'First);
361
 
362
end Ada.Containers.Indefinite_Vectors;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.