OSDN Git Service

2012-01-10 Bob Duff <duff@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / a-cfdlli.ads
index d961cb9..8bf8a3d 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---          Copyright (C) 2004-2010, Free Software Foundation, Inc.         --
+--          Copyright (C) 2004-2011, 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 --
@@ -53,6 +53,7 @@
 
 private with Ada.Streams;
 with Ada.Containers;
+with Ada.Iterator_Interfaces;
 
 generic
    type Element_Type is private;
@@ -63,7 +64,10 @@ generic
 package Ada.Containers.Formal_Doubly_Linked_Lists is
    pragma Pure;
 
-   type List (Capacity : Count_Type) is tagged private;
+   type List (Capacity : Count_Type) is tagged private with
+      Constant_Indexing => Constant_Reference,
+      Default_Iterator  => Iterate,
+      Iterator_Element  => Element_Type;
    --  pragma Preelaborable_Initialization (List);
 
    type Cursor is private;
@@ -73,6 +77,17 @@ package Ada.Containers.Formal_Doubly_Linked_Lists is
 
    No_Element : constant Cursor;
 
+   function Not_No_Element (Position : Cursor) return Boolean;
+
+   package List_Iterator_Interfaces is new
+     Ada.Iterator_Interfaces (Cursor => Cursor, Has_Element => Not_No_Element);
+
+   function Iterate (Container : List; Start : Cursor)
+      return List_Iterator_Interfaces.Reversible_Iterator'Class;
+
+   function Iterate (Container : List)
+      return List_Iterator_Interfaces.Reversible_Iterator'Class;
+
    function "=" (Left, Right : List) return Boolean;
 
    function Length (Container : List) return Count_Type;
@@ -225,6 +240,15 @@ package Ada.Containers.Formal_Doubly_Linked_Lists is
 
    end Generic_Sorting;
 
+   type Constant_Reference_Type
+      (Element : not null access constant Element_Type) is private
+   with
+      Implicit_Dereference => Element;
+
+   function Constant_Reference
+     (Container : List;      --  SHOULD BE ALIASED ???
+      Position  : Cursor)   return Constant_Reference_Type;
+
    function Strict_Equal (Left, Right : List) return Boolean;
    --  Strict_Equal returns True if the containers are physically equal, i.e.
    --  they are structurally equal (function "=" returns True) and that they
@@ -244,40 +268,22 @@ private
    type Node_Type is record
       Prev    : Count_Type'Base := -1;
       Next    : Count_Type;
-      Element : Element_Type;
+      Element : aliased Element_Type;
    end record;
+
    function "=" (L, R : Node_Type) return Boolean is abstract;
 
    type Node_Array is array (Count_Type range <>) of Node_Type;
    function "=" (L, R : Node_Array) return Boolean is abstract;
 
-   type List_Access is access all List;
-   for List_Access'Storage_Size use 0;
-
-   type Kind is (Plain, Part);
-
-   type Plain_List (Capacity : Count_Type) is record
+   type List (Capacity : Count_Type) is tagged record
       Nodes  : Node_Array (1 .. Capacity) := (others => <>);
       Free   : Count_Type'Base := -1;
       Busy   : Natural := 0;
       Lock   : Natural := 0;
-   end record;
-
-   type PList_Access is access Plain_List;
-
-   type Part_List is record
-      LLength : Count_Type := 0;
-      LFirst  : Count_Type := 0;
-      LLast   : Count_Type := 0;
-   end record;
-
-   type List (Capacity : Count_Type) is tagged record
-      K      : Kind := Plain;
       Length : Count_Type := 0;
       First  : Count_Type := 0;
       Last   : Count_Type := 0;
-      Part   : Part_List;
-      Plain  : PList_Access := new Plain_List'(Capacity, others => <>);
    end record;
 
    use Ada.Streams;
@@ -294,6 +300,9 @@ private
 
    for List'Write use Write;
 
+   type List_Access is access all List;
+   for List_Access'Storage_Size use 0;
+
    type Cursor is record
       Node : Count_Type := 0;
    end record;
@@ -314,4 +323,7 @@ private
 
    No_Element : constant Cursor := (Node => 0);
 
+   type Constant_Reference_Type
+      (Element : not null access constant Element_Type) is null record;
+
 end Ada.Containers.Formal_Doubly_Linked_Lists;