OSDN Git Service

2010-01-26 Thomas Quinot <quinot@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / a-ciorse.ads
index 0841bc7..5e73351 100644 (file)
@@ -2,12 +2,11 @@
 --                                                                          --
 --                         GNAT LIBRARY COMPONENTS                          --
 --                                                                          --
---                      A D A . C O N T A I N E R S .                       --
---              I N D E F I N I T E _ O R D E R E D _ S E T S               --
+--                 ADA.CONTAINERS.INDEFINITE_ORDERED_SETS                   --
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---          Copyright (C) 2004-2005 Free Software Foundation, Inc.          --
+--          Copyright (C) 2004-2009, Free Software Foundation, Inc.         --
 --                                                                          --
 -- This specification is derived from the Ada Reference Manual for use with --
 -- GNAT. The copyright notice above, and the license provisions that follow --
 --                                                                          --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
--- ware  Foundation;  either version 2,  or (at your option) any later ver- --
+-- ware  Foundation;  either version 3,  or (at your option) any later ver- --
 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
--- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
--- for  more details.  You should have  received  a copy of the GNU General --
--- Public License  distributed with GNAT;  see file COPYING.  If not, write --
--- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
--- MA 02111-1307, USA.                                                      --
+-- or FITNESS FOR A PARTICULAR PURPOSE.                                     --
 --                                                                          --
--- As a special exception,  if other files  instantiate  generics from this --
--- unit, or you link  this unit with other files  to produce an executable, --
--- this  unit  does not  by itself cause  the resulting  executable  to  be --
--- covered  by the  GNU  General  Public  License.  This exception does not --
--- however invalidate  any other reasons why  the executable file  might be --
--- covered by the  GNU Public License.                                      --
+-- As a special exception under Section 7 of GPL version 3, you are granted --
+-- additional permissions described in the GCC Runtime Library Exception,   --
+-- version 3.1, as published by the Free Software Foundation.               --
+--                                                                          --
+-- You should have received a copy of the GNU General Public License and    --
+-- a copy of the GCC Runtime Library Exception along with this program;     --
+-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
+-- <http://www.gnu.org/licenses/>.                                          --
 --                                                                          --
 -- This unit was originally developed by Matthew J Heaney.                  --
 ------------------------------------------------------------------------------
 
-with Ada.Containers.Red_Black_Trees;
-with Ada.Finalization;
-with Ada.Streams;
+private with Ada.Containers.Red_Black_Trees;
+private with Ada.Finalization;
+private with Ada.Streams;
 
 generic
    type Element_Type (<>) is private;
@@ -45,11 +42,16 @@ generic
    with function "=" (Left, Right : Element_Type) return Boolean is <>;
 
 package Ada.Containers.Indefinite_Ordered_Sets is
-pragma Preelaborate (Indefinite_Ordered_Sets);
+   pragma Preelaborate;
+   pragma Remote_Types;
+
+   function Equivalent_Elements (Left, Right : Element_Type) return Boolean;
 
    type Set is tagged private;
+   pragma Preelaborable_Initialization (Set);
 
    type Cursor is private;
+   pragma Preelaborable_Initialization (Cursor);
 
    Empty_Set : constant Set;
 
@@ -59,6 +61,8 @@ pragma Preelaborate (Indefinite_Ordered_Sets);
 
    function Equivalent_Sets (Left, Right : Set) return Boolean;
 
+   function To_Set (New_Item : Element_Type) return Set;
+
    function Length (Container : Set) return Count_Type;
 
    function Is_Empty (Container : Set) return Boolean;
@@ -67,15 +71,15 @@ pragma Preelaborate (Indefinite_Ordered_Sets);
 
    function Element (Position : Cursor) return Element_Type;
 
+   procedure Replace_Element
+     (Container : in out Set;
+      Position  : Cursor;
+      New_Item  : Element_Type);
+
    procedure Query_Element
      (Position : Cursor;
       Process  : not null access procedure (Element : Element_Type));
 
-   procedure Replace_Element
-     (Container : Set;   --  TODO: need ruling from ARG
-      Position  : Cursor;
-      By        : Element_Type);
-
    procedure Move (Target : in out Set; Source : in out Set);
 
    procedure Insert
@@ -96,6 +100,10 @@ pragma Preelaborate (Indefinite_Ordered_Sets);
      (Container : in out Set;
       New_Item  : Element_Type);
 
+   procedure Exclude
+     (Container : in out Set;
+      Item      : Element_Type);
+
    procedure Delete
      (Container : in out Set;
       Item      : Element_Type);
@@ -108,10 +116,6 @@ pragma Preelaborate (Indefinite_Ordered_Sets);
 
    procedure Delete_Last (Container : in out Set);
 
-   procedure Exclude
-     (Container : in out Set;
-      Item      : Element_Type);
-
    procedure Union (Target : in out Set; Source : Set);
 
    function Union (Left, Right : Set) return Set;
@@ -124,8 +128,7 @@ pragma Preelaborate (Indefinite_Ordered_Sets);
 
    function "and" (Left, Right : Set) return Set renames Intersection;
 
-   procedure Difference (Target : in out Set;
-                         Source : Set);
+   procedure Difference (Target : in out Set; Source : Set);
 
    function Difference (Left, Right : Set) return Set;
 
@@ -141,14 +144,6 @@ pragma Preelaborate (Indefinite_Ordered_Sets);
 
    function Is_Subset (Subset : Set; Of_Set : Set) return Boolean;
 
-   function Contains (Container : Set; Item : Element_Type) return Boolean;
-
-   function Find (Container : Set; Item : Element_Type) return Cursor;
-
-   function Floor (Container : Set; Item : Element_Type) return Cursor;
-
-   function Ceiling (Container : Set; Item : Element_Type) return Cursor;
-
    function First (Container : Set) return Cursor;
 
    function First_Element (Container : Set) return Element_Type;
@@ -165,6 +160,14 @@ pragma Preelaborate (Indefinite_Ordered_Sets);
 
    procedure Previous (Position : in out Cursor);
 
+   function Find (Container : Set; Item : Element_Type) return Cursor;
+
+   function Floor (Container : Set; Item : Element_Type) return Cursor;
+
+   function Ceiling (Container : Set; Item : Element_Type) return Cursor;
+
+   function Contains (Container : Set; Item : Element_Type) return Boolean;
+
    function Has_Element (Position : Cursor) return Boolean;
 
    function "<" (Left, Right : Cursor) return Boolean;
@@ -188,21 +191,28 @@ pragma Preelaborate (Indefinite_Ordered_Sets);
       Process   : not null access procedure (Position : Cursor));
 
    generic
-      type Key_Type (<>) is limited private;
+      type Key_Type (<>) is private;
 
       with function Key (Element : Element_Type) return Key_Type;
 
-      with function "<" (Left : Key_Type; Right : Element_Type)
-          return Boolean is <>;
-
-      with function ">" (Left : Key_Type; Right : Element_Type)
-          return Boolean is <>;
+      with function "<" (Left, Right : Key_Type) return Boolean is <>;
 
    package Generic_Keys is
 
-      function Contains
-        (Container : Set;
-         Key       : Key_Type) return Boolean;
+      function Equivalent_Keys (Left, Right : Key_Type) return Boolean;
+
+      function Key (Position : Cursor) return Key_Type;
+
+      function Element (Container : Set; Key : Key_Type) return Element_Type;
+
+      procedure Replace
+        (Container : in out Set;
+         Key       : Key_Type;
+         New_Item  : Element_Type);
+
+      procedure Exclude (Container : in out Set; Key : Key_Type);
+
+      procedure Delete (Container : in out Set; Key : Key_Type);
 
       function Find
         (Container : Set;
@@ -216,28 +226,9 @@ pragma Preelaborate (Indefinite_Ordered_Sets);
         (Container : Set;
          Key       : Key_Type) return Cursor;
 
-      function Key (Position : Cursor) return Key_Type;
-
-      function Element
+      function Contains
         (Container : Set;
-         Key       : Key_Type) return Element_Type;
-
-      procedure Replace
-        (Container : in out Set;  --  TODO: need ruling from ARG
-         Key       : Key_Type;
-         New_Item  : Element_Type);
-
-      procedure Delete (Container : in out Set; Key : Key_Type);
-
-      procedure Exclude (Container : in out Set; Key : Key_Type);
-
-      function "<" (Left : Cursor; Right : Key_Type) return Boolean;
-
-      function ">" (Left : Cursor; Right : Key_Type) return Boolean;
-
-      function "<" (Left : Key_Type; Right : Cursor) return Boolean;
-
-      function ">" (Left : Key_Type; Right : Cursor) return Boolean;
+         Key       : Key_Type) return Boolean;
 
       procedure Update_Element_Preserving_Key
         (Container : in out Set;
@@ -249,6 +240,9 @@ pragma Preelaborate (Indefinite_Ordered_Sets);
 
 private
 
+   pragma Inline (Next);
+   pragma Inline (Previous);
+
    type Node_Type;
    type Node_Access is access Node_Type;
 
@@ -270,13 +264,16 @@ private
       Tree : Tree_Types.Tree_Type;
    end record;
 
+   overriding
    procedure Adjust (Container : in out Set);
 
+   overriding
    procedure Finalize (Container : in out Set) renames Clear;
 
    use Red_Black_Trees;
    use Tree_Types;
    use Ada.Finalization;
+   use Ada.Streams;
 
    type Set_Access is access all Set;
    for Set_Access'Storage_Size use 0;
@@ -286,18 +283,28 @@ private
       Node      : Node_Access;
    end record;
 
-   No_Element : constant Cursor := Cursor'(null, null);
+   procedure Write
+     (Stream : not null access Root_Stream_Type'Class;
+      Item   : Cursor);
 
-   use Ada.Streams;
+   for Cursor'Write use Write;
+
+   procedure Read
+     (Stream : not null access Root_Stream_Type'Class;
+      Item   : out Cursor);
+
+   for Cursor'Read use Read;
+
+   No_Element : constant Cursor := Cursor'(null, null);
 
    procedure Write
-     (Stream    : access Root_Stream_Type'Class;
+     (Stream    : not null access Root_Stream_Type'Class;
       Container : Set);
 
    for Set'Write use Write;
 
    procedure Read
-     (Stream    : access Root_Stream_Type'Class;
+     (Stream    : not null access Root_Stream_Type'Class;
       Container : out Set);
 
    for Set'Read use Read;