OSDN Git Service

2006-10-31 Javier Miranda <miranda@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / a-coorse.ads
index 8ba0498..2cc8acc 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---          Copyright (C) 2004-2005 Free Software Foundation, Inc.          --
+--          Copyright (C) 2004-2006, 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 --
@@ -38,18 +38,21 @@ with Ada.Finalization;
 with Ada.Streams;
 
 generic
-
    type Element_Type is private;
 
    with function "<" (Left, Right : Element_Type) return Boolean is <>;
    with function "=" (Left, Right : Element_Type) return Boolean is <>;
 
 package Ada.Containers.Ordered_Sets is
-pragma Preelaborate (Ordered_Sets);
+   pragma Preelaborate;
+
+   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 +62,8 @@ pragma Preelaborate (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,18 +72,16 @@ pragma Preelaborate (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 ARG ruling
-      Position  : Cursor;
-      By        : Element_Type);
-
-   procedure Move
-     (Target : in out Set;
-      Source : in out Set);
+   procedure Move (Target : in out Set; Source : in out Set);
 
    procedure Insert
      (Container : in out Set;
@@ -95,9 +98,13 @@ pragma Preelaborate (Ordered_Sets);
       New_Item  : Element_Type);
 
    procedure Replace
-     (Container : in out Set;  --  TODO: need ARG ruling
+     (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);
@@ -110,10 +117,6 @@ pragma Preelaborate (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;
@@ -126,8 +129,7 @@ pragma Preelaborate (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;
 
@@ -143,14 +145,6 @@ pragma Preelaborate (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;
@@ -167,6 +161,14 @@ pragma Preelaborate (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;
@@ -190,48 +192,36 @@ pragma Preelaborate (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 Find (Container : Set; Key : Key_Type) return Cursor;
-
-      function Floor (Container : Set; Key : Key_Type) return Cursor;
-
-      function Ceiling (Container : Set; Key : Key_Type) return Cursor;
+      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;  --  TODO: need ARG ruling
+        (Container : in out Set;
          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;
+      procedure Delete (Container : in out Set; Key : Key_Type);
+
+      function Find (Container : Set; Key : Key_Type) return Cursor;
 
-      function ">" (Left : Cursor; Right : Key_Type) return Boolean;
+      function Floor (Container : Set; Key : Key_Type) return Cursor;
 
-      function "<" (Left : Key_Type; Right : Cursor) return Boolean;
+      function Ceiling (Container : Set; Key : Key_Type) return Cursor;
 
-      function ">" (Left : Key_Type; Right : Cursor) return Boolean;
+      function Contains (Container : Set; Key : Key_Type) return Boolean;
 
       procedure Update_Element_Preserving_Key
         (Container : in out Set;
@@ -269,6 +259,7 @@ private
    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;
@@ -278,9 +269,19 @@ private
       Node      : Node_Access;
    end record;
 
-   No_Element : constant Cursor := Cursor'(null, null);
+   procedure Write
+     (Stream : access Root_Stream_Type'Class;
+      Item   : Cursor);
 
-   use Ada.Streams;
+   for Cursor'Write use Write;
+
+   procedure Read
+     (Stream : 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;