1------------------------------------------------------------------------------ 2-- -- 3-- GNAT LIBRARY COMPONENTS -- 4-- -- 5-- ADA.CONTAINERS.FUNCTIONAL_BASE -- 6-- -- 7-- S p e c -- 8-- -- 9-- Copyright (C) 2016-2018, 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 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. -- 21-- -- 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. -- 25-- -- 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. 34 35pragma Ada_2012; 36 37private generic 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. 41 42 type Element_Type (<>) is private; 43 with function "=" (Left, Right : Element_Type) return Boolean is <>; 44 45package Ada.Containers.Functional_Base with SPARK_Mode => Off is 46 47 subtype Extended_Index is Index_Type'Base range 48 Index_Type'Pred (Index_Type'First) .. Index_Type'Last; 49 50 type Container is private; 51 52 function "=" (C1 : Container; C2 : Container) return Boolean; 53 -- Return True if C1 and C2 contain the same elements at the same position 54 55 function Length (C : Container) return Count_Type; 56 -- Number of elements stored in C 57 58 function Get (C : Container; I : Index_Type) return Element_Type; 59 -- Access to the element at index I in C 60 61 function Set 62 (C : Container; 63 I : Index_Type; 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. 67 68 function Add 69 (C : Container; 70 I : Index_Type; 71 E : Element_Type) return Container; 72 -- Return a new container that is C with E inserted at index I 73 74 function Remove (C : Container; I : Index_Type) return Container; 75 -- Return a new container that is C without the element at index I 76 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. 80 81 -------------------- 82 -- Set Operations -- 83 -------------------- 84 85 function "<=" (C1 : Container; C2 : Container) return Boolean; 86 -- Return True if every element of C1 is in C2 87 88 function Num_Overlaps (C1 : Container; C2 : Container) return Count_Type; 89 -- Return the number of elements that are in both C1 and C2 90 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 93 -- in C1. 94 95 function Intersection (C1 : Container; C2 : Container) return Container; 96 -- Return a container which is C1 minus all the elements that are also in 97 -- C2. 98 99private 100 101 subtype Positive_Count_Type is Count_Type range 1 .. Count_Type'Last; 102 103 type Element_Access is access all Element_Type; 104 105 type Element_Array is 106 array (Positive_Count_Type range <>) of Element_Access; 107 108 type Element_Array_Access is not null access Element_Array; 109 110 Empty_Element_Array_Access : constant Element_Array_Access := 111 new Element_Array'(1 .. 0 => null); 112 113 type Container is record 114 Elements : Element_Array_Access := Empty_Element_Array_Access; 115 end record; 116 117end Ada.Containers.Functional_Base; 118