1 ------------------------------------------------------------------------------
3 -- GNAT LIBRARY COMPONENTS --
5 -- ADA.CONTAINERS.FUNCTIONAL_VECTORS --
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 ------------------------------------------------------------------------------
33 package body Ada
.Containers
.Functional_Vectors
with SPARK_Mode
=> Off
is
40 function "<" (Left
: Sequence
; Right
: Sequence
) return Boolean is
41 (Length
(Left
.Content
) < Length
(Right
.Content
)
42 and then (for all I
in Index_Type
'First .. Last
(Left
) =>
43 Get
(Left
.Content
, I
) = Get
(Right
.Content
, I
)));
49 function "<=" (Left
: Sequence
; Right
: Sequence
) return Boolean is
50 (Length
(Left
.Content
) <= Length
(Right
.Content
)
51 and then (for all I
in Index_Type
'First .. Last
(Left
) =>
52 Get
(Left
.Content
, I
) = Get
(Right
.Content
, I
)));
58 function "=" (Left
: Sequence
; Right
: Sequence
) return Boolean is
59 (Left
.Content
= Right
.Content
);
66 (Container
: Sequence
;
67 New_Item
: Element_Type
) return Sequence
70 Add
(Container
.Content
,
71 Index_Type
'Val (Index_Type
'Pos (Index_Type
'First) +
72 Length
(Container
.Content
)),
76 (Container
: Sequence
;
77 Position
: Index_Type
;
78 New_Item
: Element_Type
) return Sequence
80 (Content
=> Add
(Container
.Content
, Position
, New_Item
));
86 function Constant_Range
87 (Container
: Sequence
;
90 Item
: Element_Type
) return Boolean is
92 for I
in Fst
.. Lst
loop
93 if Get
(Container
.Content
, I
) /= Item
then
106 (Container
: Sequence
;
108 Lst
: Extended_Index
;
109 Item
: Element_Type
) return Boolean
112 for I
in Fst
.. Lst
loop
113 if Get
(Container
.Content
, I
) = Item
then
125 function Equal_Except
128 Position
: Index_Type
) return Boolean
131 if Length
(Left
.Content
) /= Length
(Right
.Content
) then
135 for I
in Index_Type
'First .. Last
(Left
) loop
137 and then Get
(Left
.Content
, I
) /= Get
(Right
.Content
, I
)
146 function Equal_Except
150 Y
: Index_Type
) return Boolean
153 if Length
(Left
.Content
) /= Length
(Right
.Content
) then
157 for I
in Index_Type
'First .. Last
(Left
) loop
158 if I
/= X
and then I
/= Y
159 and then Get
(Left
.Content
, I
) /= Get
(Right
.Content
, I
)
172 function Get
(Container
: Sequence
;
173 Position
: Extended_Index
) return Element_Type
175 (Get
(Container
.Content
, Position
));
181 function Last
(Container
: Sequence
) return Extended_Index
is
183 ((Index_Type
'Pos (Index_Type
'First) - 1) + Length
(Container
)));
189 function Length
(Container
: Sequence
) return Count_Type
is
190 (Length
(Container
.Content
));
200 Lst
: Extended_Index
) return Boolean
203 for I
in Fst
.. Lst
loop
204 if Get
(Left
, I
) /= Get
(Right
, I
) then
216 function Range_Shifted
220 Lst
: Extended_Index
;
221 Offset
: Count_Type
'Base) return Boolean
224 for I
in Fst
.. Lst
loop
226 Get
(Right
, Index_Type
'Val (Index_Type
'Pos (I
) + Offset
))
239 (Container
: Sequence
;
240 Position
: Index_Type
) return Sequence
242 (Content
=> Remove
(Container
.Content
, Position
));
249 (Container
: Sequence
;
250 Position
: Index_Type
;
251 New_Item
: Element_Type
) return Sequence
253 (Content
=> Set
(Container
.Content
, Position
, New_Item
));
255 end Ada
.Containers
.Functional_Vectors
;