1 ------------------------------------------------------------------------------
3 -- GNAT LIBRARY COMPONENTS --
5 -- ADA.CONTAINERS.FUNCTIONAL_BASE --
9 -- Copyright (C) 2016-2017, Free Software Foundation, Inc. --
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. --
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 3, 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. --
22 -- As a special exception under Section 7 of GPL version 3, you are granted --
23 -- additional permissions described in the GCC Runtime Library Exception, --
24 -- version 3.1, as published by the Free Software Foundation. --
26 -- You should have received a copy of the GNU General Public License and --
27 -- a copy of the GCC Runtime Library Exception along with this program; --
28 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
29 -- <http://www.gnu.org/licenses/>. --
30 ------------------------------------------------------------------------------
31 -- Functional containers are neither controlled nor limited. This is safe, as
32 -- no primitives are provided to modify them.
33 -- Memory allocated inside functional containers is never reclaimed.
38 type Index_Type
is (<>);
39 -- To avoid Constraint_Error being raised at run time, Index_Type'Base
40 -- should have at least one more element at the low end than Index_Type.
42 type Element_Type
(<>) is private;
43 with function "=" (Left
, Right
: Element_Type
) return Boolean is <>;
45 package Ada
.Containers
.Functional_Base
with SPARK_Mode
=> Off
is
47 subtype Extended_Index
is Index_Type
'Base range
48 Index_Type
'Pred (Index_Type
'First) .. Index_Type
'Last;
50 type Container
is private;
52 function "=" (C1
: Container
; C2
: Container
) return Boolean;
53 -- Return True if C1 and C2 contain the same elements at the same position
55 function Length
(C
: Container
) return Count_Type
;
56 -- Number of elements stored in C
58 function Get
(C
: Container
; I
: Index_Type
) return Element_Type
;
59 -- Access to the element at index I in C
64 E
: Element_Type
) return Container
;
65 -- Return a new container which is equal to C except for the element at
66 -- index I, which is set to E.
71 E
: Element_Type
) return Container
;
72 -- Return a new container that is C with E inserted at index I
74 function Remove
(C
: Container
; I
: Index_Type
) return Container
;
75 -- Return a new container that is C without the element at index I
77 function Find
(C
: Container
; E
: Element_Type
) return Extended_Index
;
78 -- Return the first index for which the element stored in C is I. If there
79 -- are no such indexes, return Extended_Index'First.
85 function "<=" (C1
: Container
; C2
: Container
) return Boolean;
86 -- Return True if every element of C1 is in C2
88 function Num_Overlaps
(C1
: Container
; C2
: Container
) return Count_Type
;
89 -- Return the number of elements that are in both C1 and C2
91 function Union
(C1
: Container
; C2
: Container
) return Container
;
92 -- Return a container which is C1 plus all the elements of C2 that are not
95 function Intersection
(C1
: Container
; C2
: Container
) return Container
;
96 -- Return a container which is C1 minus all the elements that are also in
101 subtype Positive_Count_Type
is Count_Type
range 1 .. Count_Type
'Last;
103 type Element_Access
is access all Element_Type
;
105 type Element_Array
is
106 array (Positive_Count_Type
range <>) of Element_Access
;
108 type Element_Array_Access
is not null access Element_Array
;
110 Empty_Element_Array_Access
: constant Element_Array_Access
:=
111 new Element_Array
'(1 .. 0 => null);
113 type Container is record
114 Elements : Element_Array_Access := Empty_Element_Array_Access;
117 end Ada.Containers.Functional_Base;