Annotated Ada Reference Manual (Ada 202y Draft 1)Legal Information
Contents   Index   References   Search   Previous   Next 

A.18.3 The Generic Package Containers.Doubly_Linked_Lists

1/2
{AI95-00302-03} The language-defined generic package Containers.Doubly_Linked_Lists provides private types List and Cursor, and a set of operations for each type. A list container is optimized for insertion and deletion at any position.
2/2
{AI95-00302-03} A doubly-linked list container object manages a linked list of internal nodes, each of which contains an element and pointers to the next (successor) and previous (predecessor) internal nodes. A cursor designates a particular node within a list (and by extension the element contained in that node). A cursor keeps designating the same node (and element) as long as the node is part of the container, even if the node is moved in the container.
3/2
{AI95-00302-03} The length of a list is the number of elements it contains.

Static Semantics

4/2
{AI95-00302-03} The generic library package Containers.Doubly_Linked_Lists has the following declaration: 
5/5
{AI05-0084-1} {AI05-0212-1} {AI12-0112-1} with Ada.Iterator_Interfaces;
generic
   type Element_Type is private;
   with function "=" (Left, Right : Element_Type)
      return Boolean is <>;
package Ada.Containers.Doubly_Linked_Lists
   with Preelaborate, Remote_Types,
        Nonblocking, Global => in out synchronized is
5.a/5
Discussion: {AI12-0112-1} For discussion on the reasons and meaning of the specifications of the Global and Nonblocking aspects in this generic package, see the notes on the equivalent operations in the specification of the Containers.Vectors package (see A.18.2). 
6/5
{AI05-0212-1} {AI12-0111-1} {AI12-0112-1} {AI12-0212-1} {AI12-0339-1} {AI12-0391-1} {AI12-0399-1} {AI12-0400-1}    type List is tagged private
      with Constant_Indexing => Constant_Reference,
           Variable_Indexing => Reference,
           Default_Iterator  => Iterate,
           Iterator_Element  => Element_Type,
           Iterator_View     => Stable.List,
           Aggregate         => (Empty       => Empty,
                                 Add_Unnamed => Append),
           Stable_Properties => (Length,
                                 Tampering_With_Cursors_Prohibited,
                                 Tampering_With_Elements_Prohibited),
           Default_Initial_Condition =>
              Length (List) = 0 and then
              (not Tampering_With_Cursors_Prohibited (List)) and then
              (not Tampering_With_Elements_Prohibited (List)),
           Preelaborable_Initialization;
7/5
{AI12-0399-1}    type Cursor is private
      with Preelaborable_Initialization;
8/2
   Empty_List : constant List;
9/2
   No_Element : constant Cursor;
9.1/5
{AI05-0212-1} {AI12-0112-1}    function Has_Element (Position : Cursor) return Boolean
      with Nonblocking, Global => in all, Use_Formal => null;
9.2/5
{AI12-0112-1}    function Has_Element (Container : List; Position : Cursor)
      return Boolean
      with Nonblocking, Global => null, Use_Formal => null;
9.3/3
{AI05-0212-1}    package List_Iterator_Interfaces is new
       Ada.Iterator_Interfaces (Cursor, Has_Element);
10/2
   function "=" (Left, Right : List) return Boolean;
10.1/5
{AI12-0112-1}    function Tampering_With_Cursors_Prohibited
      (Container : List) return Boolean
      with Nonblocking, Global => null, Use_Formal => null;
10.2/5
{AI12-0112-1}    function Tampering_With_Elements_Prohibited
      (Container : List) return Boolean
      with Nonblocking, Global => null, Use_Formal => null;
10.3/5
{AI12-0339-1}    function Empty return List
      is (Empty_List)
      with Post =>
             not Tampering_With_Elements_Prohibited (Empty'Result) and then
             not Tampering_With_Cursors_Prohibited (Empty'Result) and then
             Length (Empty'Result) = 0;
11/5
{AI12-0112-1}    function Length (Container : List) return Count_Type
      with Nonblocking, Global => null, Use_Formal => null;
12/5
{AI12-0112-1}    function Is_Empty (Container : List) return Boolean
      with Nonblocking, Global => null, Use_Formal => null,
           Post => Is_Empty'Result = (Length (Container) = 0);
13/5
{AI12-0112-1}    procedure Clear (Container : in out List)
      with Pre  => not Tampering_With_Cursors_Prohibited (Container)
                      or else raise Program_Error,
           Post => Length (Container) = 0;
14/5
{AI12-0112-1}    function Element (Position : Cursor) return Element_Type
      with Pre  => Position /= No_Element or else raise Constraint_Error,
           Nonblocking, Global => in all, Use_Formal => Element_Type;
14.1/5
{AI12-0112-1}    function Element (Container : List;
                     Position  : Cursor) return Element_Type
      with Pre => (Position /= No_Element or else
                      raise Constraint_Error) and then
                   (Has_Element (Container, Position) 
                      or else raise Program_Error),
           Nonblocking, Global => null, Use_Formal => Element_Type;
15/5
{AI12-0112-1}    procedure Replace_Element (Container : in out List;
                              Position  : in     Cursor;
                              New_item  : in     Element_Type)
      with Pre  => (not Tampering_With_Elements_Prohibited (Container)
                      or else raise Program_Error) and then
                   (Position /= No_Element
                      or else raise Constraint_Error) and then
                   (Has_Element (Container, Position) 
                      or else raise Program_Error);
16/5
{AI12-0112-1}    procedure Query_Element
     (Position : in Cursor;
      Process  : not null access procedure (Element : in Element_Type))
      with Pre  => Position /= No_Element or else raise Constraint_Error,
           Global => in all;
16.1/5
{AI12-0112-1}    procedure Query_Element
     (Container : in List;
      Position  : in Cursor;
      Process   : not null access procedure (Element : in Element_Type))
      with Pre  => (Position /= No_Element
                       or else raise Constraint_Error) and then
                    (Has_Element (Container, Position)
                       or else raise Program_Error);
17/5
{AI12-0112-1}    procedure Update_Element
     (Container : in out List;
      Position  : in     Cursor;
      Process   : not null access procedure
                      (Element : in out Element_Type))
      with Pre  => (Position /= No_Element 
                       or else raise Constraint_Error) and then
                    (Has_Element (Container, Position) 
                       or else raise Program_Error);
17.1/5
{AI05-0212-1} {AI12-0112-1}    type Constant_Reference_Type
         (Element : not null access constant Element_Type) is private
      with Implicit_Dereference => Element,
           Nonblocking, Global => in out synchronized,
           Default_Initial_Condition => (raise Program_Error);
17.2/5
{AI05-0212-1} {AI12-0112-1}    type Reference_Type (Element : not null access Element_Type) is private
      with Implicit_Dereference => Element,
           Nonblocking, Global => in out synchronized,
           Default_Initial_Condition => (raise Program_Error);
17.3/5
{AI05-0212-1} {AI12-0112-1}    function Constant_Reference (Container : aliased in List;
                                Position  : in Cursor)
      return Constant_Reference_Type
      with Pre  => (Position /= No_Element or else
                       raise Constraint_Error) and then
                    (Has_Element (Container, Position) or else
                       raise Program_Error),
           Post   => Tampering_With_Cursors_Prohibited (Container),
           Nonblocking, Global => null, Use_Formal => null;
17.4/5
{AI05-0212-1} {AI12-0112-1}    function Reference (Container : aliased in out List;
                       Position  : in Cursor)
      return Reference_Type
      with Pre  => (Position /= No_Element or else
                       raise Constraint_Error) and then
                    (Has_Element (Container, Position) or else
                       raise Program_Error),
           Post   => Tampering_With_Cursors_Prohibited (Container),
           Nonblocking, Global => null, Use_Formal => null;
17.5/5
{AI05-0001-1} {AI12-0112-1}    procedure Assign (Target : in out List; Source : in List)
      with Pre  => not Tampering_With_Cursors_Prohibited (Target)
                      or else raise Program_Error,
           Post => Length (Source) = Length (Target);
17.6/5
{AI05-0001-1} {AI12-0112-1}    function Copy (Source : List)
      return List
      with Post => 
              Length (Copy'Result) = Length (Source) and then
              not Tampering_With_Elements_Prohibited (Copy'Result) and then
              not Tampering_With_Cursors_Prohibited (Copy'Result);
18/5
{AI12-0112-1}    procedure Move (Target : in out List;
                   Source : in out List)
      with Pre  => (not Tampering_With_Cursors_Prohibited (Target)
                      or else raise Program_Error) and then
                   (not Tampering_With_Cursors_Prohibited (Source)
                      or else raise Program_Error),
            Post => (if not Target'Has_Same_Storage (Source) then
                      Length (Target) = Length (Source'Old) and then
                      Length (Source) = 0);
19/5
{AI12-0112-1}    procedure Insert (Container : in out List;
                     Before    : in     Cursor;
                     New_Item  : in     Element_Type;
                     Count     : in     Count_Type := 1)
      with Pre  => (not Tampering_With_Cursors_Prohibited (Container)
                      or else raise Program_Error) and then
                   (Before = No_Element or else
                    Has_Element (Container, Before)
                      or else raise Program_Error) and then
                   (Length (Container) <= Count_Type'Last - Count
                      or else raise Constraint_Error),
           Post => Length (Container)'Old + Count = Length (Container);
20/5
{AI12-0112-1}    procedure Insert (Container : in out List;
                     Before    : in     Cursor;
                     New_Item  : in     Element_Type;
                     Position  :    out Cursor;
                     Count     : in     Count_Type := 1)
      with Pre  => (not Tampering_With_Cursors_Prohibited (Container)
                      or else raise Program_Error) and then
                   (Before = No_Element or else
                    Has_Element (Container, Before)
                      or else raise Program_Error) and then
                   (Length (Container) <= Count_Type'Last - Count
                      or else raise Constraint_Error),
           Post => Length (Container)'Old + Count = Length (Container)
                   and then Has_Element (Container, Position);
21/5
{AI12-0112-1}    procedure Insert (Container : in out List;
                     Before    : in     Cursor;
                     Position  :    out Cursor;
                     Count     : in     Count_Type := 1)
      with Pre  => (not Tampering_With_Cursors_Prohibited (Container)
                      or else raise Program_Error) and then
                   (Before = No_Element or else
                    Has_Element (Container, Before)
                      or else raise Program_Error) and then
                   (Length (Container) <= Count_Type'Last - Count
                      or else raise Constraint_Error),
           Post => Length (Container)'Old + Count = Length (Container)
                   and then Has_Element (Container, Position);
22/5
{AI12-0112-1}    procedure Prepend (Container : in out List;
                      New_Item  : in     Element_Type;
                      Count     : in     Count_Type := 1)
      with Pre  => (not Tampering_With_Cursors_Prohibited (Container)
                       or else raise Program_Error) and then
                    (Length (Container) <= Count_Type'Last - Count
                       or else raise Constraint_Error),
           Post => Length (Container)'Old + Count = Length (Container);
23/5
{AI12-0112-1} {AI12-0400-1}    procedure Append (Container : in out List;
                     New_Item  : in     Element_Type;
                     Count     : in     Count_Type)
      with Pre  => (not Tampering_With_Cursors_Prohibited (Container)
                       or else raise Program_Error) and then
                   (Length (Container) <= Count_Type'Last - Count
                       or else raise Constraint_Error),
           Post => Length (Container)'Old + Count = Length (Container);
23.1/5
{AI12-0391-1} {AI12-0400-1}    procedure Append (Container : in out List;
                     New_Item  : in     Element_Type)
      with Pre  => (not Tampering_With_Cursors_Prohibited (Container)
                       or else raise Program_Error) and then
                   (Length (Container) <= Count_Type'Last - 1
                       or else raise Constraint_Error),
           Post => Length (Container)'Old + 1 = Length (Container);
24/5
{AI12-0112-1}    procedure Delete (Container : in out List;
                     Position  : in out Cursor;
                     Count     : in     Count_Type := 1)
      with Pre  => (not Tampering_With_Cursors_Prohibited (Container)
                      or else raise Program_Error) and then
                   (Position /= No_Element
                      or else raise Constraint_Error) and then
                   (Has_Element (Container, Position)
                      or else raise Program_Error),
           Post => Length (Container)'Old - Count <= Length (Container)
                   and then Position = No_Element;
25/5
{AI12-0112-1}    procedure Delete_First (Container : in out List;
                           Count     : in     Count_Type := 1)
      with Pre  => not Tampering_With_Cursors_Prohibited (Container)
                       or else raise Program_Error,
           Post => Length (Container)'Old - Count <= Length (Container);
26/5
{AI12-0112-1}    procedure Delete_Last (Container : in out List;
                          Count     : in     Count_Type := 1)
      with Pre  => not Tampering_With_Cursors_Prohibited (Container)
                       or else raise Program_Error,
           Post => Length (Container)'Old - Count <= Length (Container);
27/5
{AI12-0112-1}    procedure Reverse_Elements (Container : in out List)
      with Pre  => not Tampering_With_Cursors_Prohibited (Container)
                       or else raise Program_Error;
28/5
{AI12-0112-1}    procedure Swap (Container : in out List;
                   I, J      : in     Cursor)
      with Pre  => (not Tampering_With_Elements_Prohibited (Container)
                      or else raise Program_Error) and then
                   (I /= No_Element or else Constraint_Error) and then
                   (J /= No_Element or else Constraint_Error) and then
                   (Has_Element (Container, I)
                      or else raise Program_Error) and then
                   (Has_Element (Container, J)
                      or else raise Program_Error);
29/5
{AI12-0112-1}    procedure Swap_Links (Container : in out List;
                         I, J      : in     Cursor)
      with Pre  => (not Tampering_With_Elements_Prohibited (Container)
                       or else raise Program_Error) and then
                   (I /= No_Element or else Constraint_Error) and then
                   (J /= No_Element or else Constraint_Error) and then
                   (Has_Element (Container, I)
                       or else raise Program_Error) and then
                   (Has_Element (Container, J)
                       or else raise Program_Error);
30/5
{AI12-0112-1}    procedure Splice (Target   : in out List;
                     Before   : in     Cursor;
                     Source   : in out List)
      with Pre  => (not Tampering_With_Cursors_Prohibited (Target)
                      or else raise Program_Error) and then
                   (not Tampering_With_Cursors_Prohibited (Source)
                      or else raise Program_Error) and then
                   (Before = No_Element or else
                    Has_Element (Target, Before)
                      or else raise Program_Error) and then
                   (Target'Has_Same_Storage (Source) or else
                    Length (Target) <= Count_Type'Last - Length (Source)
                      or else raise Constraint_Error),
           Post => (if not Target'Has_Same_Storage (Source) then
                      (declare
                         Result_Length : constant Count_Type :=
                            Length (Source)'Old + Length (Target)'Old;
                       begin
                         Length (Source) = 0 and then
                         Length (Target) = Result_Length));
31/5
{AI12-0112-1}    procedure Splice (Target   : in out List;
                     Before   : in     Cursor;
                     Source   : in out List;
                     Position : in out Cursor)
      with Pre  => (not Tampering_With_Cursors_Prohibited (Target)
                      or else raise Program_Error) and then
                   (not Tampering_With_Cursors_Prohibited (Source)
                      or else raise Program_Error) and then
                   (Position /= No_Element
                      or else raise Constraint_Error) and then
                   (Has_Element (Source, Position)
                      or else raise Program_Error) and then
                   (Before = No_Element or else
                    Has_Element (Target, Before)
                      or else raise Program_Error) and then
                   (Target'Has_Same_Storage (Source) or else
                    Length (Target) <= Count_Type'Last - 1
                      or else raise Constraint_Error),
           Post => (declare
                      Org_Target_Length : constant Count_Type :=
                         Length (Target)'Old;
                      Org_Source_Length : constant Count_Type :=
                         Length (Source)'Old;
                    begin
                       (if Target'Has_Same_Storage (Source) then
                           Position = Position'Old
                        else 
                           Length (Source) = Org_Source_Length - 1 and then
                           Length (Target) = Org_Target_Length + 1 and then
                           Has_Element (Target, Position)));
32/2
   procedure Splice (Container: in out List;
                     Before   : in     Cursor;
                     Position : in     Cursor)
      with Pre  => (not Tampering_With_Cursors_Prohibited (Container)
                      or else raise Program_Error) and then
                   (Position /= No_Element
                      or else raise Constraint_Error) and then
                   (Has_Element (Container, Position)
                      or else raise Program_Error) and then
                   (Before = No_Element or else
                    Has_Element (Container, Before)
                      or else raise Program_Error),
           Post =>  Length (Container) = Length (Container)'Old;
33/5
{AI12-0112-1}    function First (Container : List) return Cursor
      with Nonblocking, Global => null, Use_Formal => null,
           Post => (if not Is_Empty (Container)
                    then Has_Element (Container, First'Result)
                    else First'Result = No_Element);
34/5
{AI12-0112-1}    function First_Element (Container : List)
      return Element_Type
      with Pre => (not Is_Empty (Container) 
                      or else raise Constraint_Error);
35/5
{AI12-0112-1}    function Last (Container : List) return Cursor
      with Nonblocking, Global => null, Use_Formal => null,
           Post => (if not Is_Empty (Container)
                    then Has_Element (Container, Last'Result)
                    else Last'Result = No_Element);
36/5
{AI12-0112-1}    function Last_Element (Container : List)
      return Element_Type
      with Pre => (not Is_Empty (Container) 
                      or else raise Constraint_Error);
37/5
{AI12-0112-1}    function Next (Position : Cursor) return Cursor
      with Nonblocking, Global => in all, Use_Formal => null,
           Post => (if Position = No_Element then Next'Result = No_Element);
37.1/5
{AI12-0112-1}    function Next (Container : List;
                  Position : Cursor) return Cursor
      with Nonblocking, Global => null, Use_Formal => null,
           Pre  => Position = No_Element or else
                   Has_Element (Container, Position)
                      or else raise Program_Error,
           Post => (if Position = No_Element then Next'Result = No_Element
                    elsif Next'Result = No_Element then
                      Position = Last (Container)
                    else Has_Element (Container, Next'Result));
38/5
{AI12-0112-1}    function Previous (Position : Cursor) return Cursor
      with Nonblocking, Global => in all, Use_Formal => null,
           Post => (if Position = No_Element then 
                      Previous'Result = No_Element);
38.1/5
{AI12-0112-1}    function Previous (Container : List;
                      Position  : Cursor) return Cursor
      with Nonblocking, Global => null, Use_Formal => null,
           Pre  => Position = No_Element or else
                   Has_Element (Container, Position)
                      or else raise Program_Error,
           Post => (if Position = No_Element then 
                      Previous'Result = No_Element
                    elsif Previous'Result = No_Element then
                      Position = First (Container)
                    else Has_Element (Container, Previous'Result));
39/5
{AI12-0112-1}    procedure Next (Position : in out Cursor)
      with Nonblocking, Global => in all, Use_Formal => null;
39.1/5
{AI12-0112-1}    procedure Next (Container : in     List;
                   Position  : in out Cursor)
      with Nonblocking, Global => null, Use_Formal => null,
           Pre  => Position = No_Element or else
                   Has_Element (Container, Position)
                      or else raise Program_Error,
           Post => (if Position /= No_Element
                    then Has_Element (Container, Position));
40/5
{AI12-0112-1}    procedure Previous (Position : in out Cursor)
      with Nonblocking, Global => in all, Use_Formal => null;
40.1/5
{AI12-0112-1}    procedure Previous (Container : in     List;
                       Position  : in out Cursor)
      with Nonblocking, Global => null, Use_Formal => null,
           Pre  => Position = No_Element or else
                   Has_Element (Container, Position)
                      or else raise Program_Error,
           Post => (if Position /= No_Element then 
                      Has_Element (Container, Position));
41/5
{AI12-0112-1}    function Find (Container : List;
                  Item      : Element_Type;
                  Position  : Cursor := No_Element)
      return Cursor
      with Pre  => Position = No_Element or else
                   Has_Element (Container, Position)
                      or else raise Program_Error,
           Post => (if Find'Result /= No_Element
                    then Has_Element (Container, Find'Result));
42/5
{AI12-0112-1}    function Reverse_Find (Container : List;
                          Item      : Element_Type;
                          Position  : Cursor := No_Element)
      return Cursor
      with Pre  => Position = No_Element or else
                   Has_Element (Container, Position)
                      or else raise Program_Error,
           Post => (if Reverse_Find'Result /= No_Element
                    then Has_Element (Container, Reverse_Find'Result));
43/2
   function Contains (Container : List;
                      Item      : Element_Type) return Boolean;
44/3
This paragraph was deleted.{AI05-0212-1}
45/5
{AI12-0112-1}    procedure  Iterate
     (Container : in List;
      Process   : not null access procedure (Position : in Cursor))
      with Allows_Exit;
46/5
{AI12-0112-1}    procedure Reverse_Iterate
     (Container : in List;
      Process   : not null access procedure (Position : in Cursor))
      with Allows_Exit;
46.1/5
{AI05-0212-1} {AI12-0112-1} {AI12-0266-1}    function Iterate (Container : in List)
      return List_Iterator_Interfaces.Parallel_Reversible_Iterator'Class
      with Post   => Tampering_With_Cursors_Prohibited (Container);
46.2/5
{AI05-0212-1} {AI12-0112-1}    function Iterate (Container : in List; Start : in Cursor)
      return List_Iterator_Interfaces.Reversible_Iterator'Class
      with Pre    => (Start /= No_Element
                        or else raise Constraint_Error) and then
                     (Has_Element (Container, Start)
                        or else raise Program_Error),
           Post   => Tampering_With_Cursors_Prohibited (Container);
47/5
{AI12-0112-1}    generic
      with function "<" (Left, Right : Element_Type)
         return Boolean is <>;
   package Generic_Sorting
   with Nonblocking, Global => null is
48/2
      function Is_Sorted (Container : List) return Boolean;
49/5
{AI12-0112-1}       procedure Sort (Container : in out List)
         with Pre  => not Tampering_With_Cursors_Prohibited (Container)
                          or else raise Program_Error;
50/5
{AI12-0112-1}       procedure Merge (Target  : in out List;
                       Source  : in out List)
         with Pre  => (not Tampering_With_Cursors_Prohibited (Target)
                         or else raise Program_Error) and then
                      (not Tampering_With_Elements_Prohibited (Source)
                         or else raise Program_Error) and then
                      (Length (Target) <= Count_Type'Last - Length (Source)
                         or else raise Constraint_Error) and then
                      ((Length (Source) = 0 or else
                         not Target'Has_Same_Storage (Source))
                         or else raise Constraint_Error),
              Post => (declare
                         Result_Length : constant Count_Type :=
                            Length (Source)'Old + Length (Target)'Old;
                       begin
                         (Length (Source) = 0 and then
                          Length (Target) = Result_Length));
51/2
   end Generic_Sorting;
51.1/5
{AI12-0111-1}    package Stable is
51.2/5
{AI12-0111-1} {AI12-0339-1} {AI12-0391-1} {AI12-0400-1} {AI12-0407-1}       type List (Base : not null access Doubly_Linked_Lists.List) is
         tagged limited private
         with Constant_Indexing => Constant_Reference,
              Variable_Indexing => Reference,
              Default_Iterator  => Iterate,
              Iterator_Element  => Element_Type,
              Stable_Properties => (Length),
              Global => null,
              Default_Initial_Condition => Length (List) = 0,
              Preelaborable_Initialization;
51.3/5
{AI12-0111-1}       type Cursor is private
         with Preelaborable_Initialization;
51.4/5
{AI12-0111-1}       Empty_List : constant List;
51.5/5
{AI12-0111-1}       No_Element : constant Cursor;
51.6/5
{AI12-0111-1}       function Has_Element (Position : Cursor) return Boolean
         with Nonblocking, Global => in all, Use_Formal => null;
51.7/5
{AI12-0111-1}       package List_Iterator_Interfaces is new
         Ada.Iterator_Interfaces (Cursor, Has_Element);
51.8/5
{AI12-0111-1}       procedure Assign (Target : in out Doubly_Linked_Lists.List;
                        Source : in List)
         with Post => Length (Source) = Length (Target);
51.9/5
{AI12-0111-1}       function Copy (Source : Doubly_Linked_Lists.List) return List
         with Post => Length (Copy'Result) = Length (Source);
51.10/5
{AI12-0111-1}       type Constant_Reference_Type
            (Element : not null access constant Element_Type) is private
         with Implicit_Dereference => Element,
              Nonblocking, Global => null, Use_Formal => null,
              Default_Initial_Condition => (raise Program_Error);
51.11/5
{AI12-0111-1}       type Reference_Type
            (Element : not null access Element_Type) is private
         with Implicit_Dereference => Element,
              Nonblocking, Global => null, Use_Formal => null,
              Default_Initial_Condition => (raise Program_Error);
51.12/5
{AI12-0111-1}       -- Additional subprograms as described in the text
      -- are declared here.
51.13/5
{AI12-0111-1}    private
51.14/5
{AI12-0111-1}       ... -- not specified by the language
51.15/5
{AI12-0111-1}    end Stable;
52/2
private
53/2
   ... -- not specified by the language
54/2
end Ada.Containers.Doubly_Linked_Lists;
55/2
{AI95-00302-03} The actual function for the generic formal function "=" on Element_Type values is expected to define a reflexive and symmetric relationship and return the same result value each time it is called with a particular pair of values. If it behaves in some other manner, the functions Find, Reverse_Find, and "=" on list values return an unspecified value. The exact arguments and number of calls of this generic formal function by the functions Find, Reverse_Find, and "=" on list values are unspecified.
55.a/2
Ramification: If the actual function for "=" is not symmetric and consistent, the result returned by the listed functions cannot be predicted. The implementation is not required to protect against "=" raising an exception, or returning random results, or any other “bad” behavior. And it can call "=" in whatever manner makes sense. But note that only the results of Find, Reverse_Find, and List "=" are unspecified; other subprograms are not allowed to break if "=" is bad (they aren't expected to use "="). 
56/2
{AI95-00302-03} The type List is used to represent lists. The type List needs finalization (see 7.6).
57/2
{AI95-00302-03} Empty_List represents the empty List object. It has a length of 0. If an object of type List is not otherwise initialized, it is initialized to the same value as Empty_List.
58/2
{AI95-00302-03} No_Element represents a cursor that designates no element. If an object of type Cursor is not otherwise initialized, it is initialized to the same value as No_Element.
59/5
{AI95-00302-03} {AI12-0434-1} The primitive "=" operator for type Cursor returns True if both cursors are No_Element, or designate the same element in the same container.
59.a/5
To be honest: {AI12-0434-1} “The primitive "=" operator” is the one with two parameters of type Cursor which returns Boolean. We're not talking about some other (hidden) primitive function named "=". 
60/2
{AI95-00302-03} Execution of the default implementation of the Input, Output, Read, or Write attribute of type Cursor raises Program_Error.
60.a/2
Reason: A cursor will probably be implemented in terms of one or more access values, and the effects of streaming access values is unspecified. Rather than letting the user stream junk by accident, we mandate that streaming of cursors raise Program_Error by default. The attributes can always be specified if there is a need to support streaming. 
60.1/5
  {AI05-0001-1} {AI05-0262-1} {AI12-0437-1} List'Write for a List object L writes Length(L) elements of the list to the stream. It may also write additional information about the list.
60.2/3
  {AI05-0001-1} {AI05-0262-1} List'Read reads the representation of a list from the stream, and assigns to Item a list with the same length and elements as was written by List'Write.
60.b/3
Ramification: Streaming more elements than the container length is wrong. For implementation implications of this rule, see the Implementation Note in A.18.2.
61/5
{AI95-00302-03} {AI12-0111-1} {AI12-0112-1} [Some operations check for “tampering with cursors” of a container because they depend on the set of elements of the container remaining constant, and others check for “tampering with elements” of a container because they depend on elements of the container not being replaced.] When tampering with cursors is prohibited for a particular list object L, Program_Error is propagated by the finalization of L[, as well as by a call that passes L to certain of the operations of this package, as indicated by the precondition of such an operation]. Similarly, when tampering with elements is prohibited for L, Program_Error is propagated by a call that passes L to certain of the other operations of this package, as indicated by the precondition of such an operation.
Paragraphs 62 through 69 are removed as preconditions now describe these rules.
65.a.1/3
Ramification: We don't need to explicitly mention assignment_statement, because that finalizes the target object as part of the operation, and finalization of an object is already defined as tampering with cursors.
69.2/5
function Has_Element (Position : Cursor) return Boolean
   with Nonblocking, Global => in all, Use_Formal => null;
69.3/3
{AI05-0212-1} Returns True if Position designates an element, and returns False otherwise.
69.c/3
To be honest: {AI05-0005-1} {AI05-0212-1} This function might not detect cursors that designate deleted elements; such cursors are invalid (see below) and the result of calling Has_Element with an invalid cursor is unspecified (but not erroneous). 
69.4/5
function Has_Element (Container : List; Position : Cursor)
   return Boolean
   with Nonblocking, Global => null, Use_Formal => null;
69.5/5
{AI12-0112-1} Returns True if Position designates an element in Container, and returns False otherwise.
69.d/5
Ramification: If Position is No_Element, Has_Element returns False. 
70/2
function "=" (Left, Right : List) return Boolean;
71/3
{AI95-00302-03} {AI05-0264-1} If Left and Right denote the same list object, then the function returns True. If Left and Right have different lengths, then the function returns False. Otherwise, it compares each element in Left to the corresponding element in Right using the generic formal equality operator. If any such comparison returns False, the function returns False; otherwise, it returns True. Any exception raised during evaluation of element equality is propagated.
71.a/2
Implementation Note: This wording describes the canonical semantics. However, the order and number of calls on the formal equality function is unspecified for all of the operations that use it in this package, so an implementation can call it as many or as few times as it needs to get the correct answer. Specifically, there is no requirement to call the formal equality additional times once the answer has been determined. 
71.1/5
function Tampering_With_Cursors_Prohibited
   (Container : List) return Boolean
   with Nonblocking, Global => null, Use_Formal => null;
71.2/5
{AI12-0112-1} Returns True if tampering with cursors or tampering with elements is currently prohibited for Container, and returns False otherwise.
71.b/5
Reason: {AI12-0112-1} Prohibiting tampering with elements also needs to prohibit tampering with cursors, as deleting an element is similar to replacing it. 
71.c/5
Implementation Note: {AI12-0112-1} Various contracts elsewhere in this specification require that this function be implemented with synchronized data. Moreover, it is possible for tampering to be prohibited by multiple operations (sequentially or in parallel). Therefore, tampering needs to be implemented with an atomic or protected counter. The counter is initialized to zero, and is incremented when tampering is prohibited, and decremented when leaving an area that prohibited tampering. Function Tampering_With_Cursors_Prohibited returns True if the counter is nonzero. (Note that any case where the result is not well-defined for one task is incorrect use of shared variables and would be erroneous by the rules of 9.10, so no special protection is needed to read the counter.) 
71.3/5
function Tampering_With_Elements_Prohibited
   (Container : List) return Boolean
   with Nonblocking, Global => null, Use_Formal => null;
71.4/5
{AI12-0112-1} Always returns False[, regardless of whether tampering with elements is prohibited].
71.d/5
Reason: {AI12-0111-1} A definite element cannot change size, so we allow operations that tamper with elements even when tampering with elements is prohibited. That's not true for the indefinite containers, which is why this kind of tampering exists. 
72/5
function Length (Container : List) return Count_Type
   with Nonblocking, Global => null, Use_Formal => null;
73/2
{AI95-00302-03} Returns the number of elements in Container.
74/5
function Is_Empty (Container : List) return Boolean
   with Nonblocking, Global => null, Use_Formal => null,
        Post => Is_Empty'Result = (Length (Container) = 0);
75/5
{AI95-00302-03} {AI12-0112-1} Returns True if Container is empty.
76/5
procedure Clear (Container : in out List)
   with Pre  => not Tampering_With_Cursors_Prohibited (Container)
                    or else raise Program_Error,
        Post => Length (Container) = 0;
77/2
{AI95-00302-03} Removes all the elements from Container.
78/5
function Element (Position : Cursor) return Element_Type
   with Pre  => Position /= No_Element or else raise Constraint_Error,
        Nonblocking, Global => in all, Use_Formal => Element_Type;
79/5
{AI95-00302-03} {AI12-0112-1} Element returns the element designated by Position.
79.1/5
function Element (Container : List;
                  Position  : Cursor) return Element_Type
   with Pre => (Position /= No_Element or else
                   raise Constraint_Error) and then
                (Has_Element (Container, Position) 
                   or else raise Program_Error),
        Nonblocking, Global => null, Use_Formal => Element_Type;
79.2/5
{AI12-0112-1} Element returns the element designated by Position in Container.
80/5
procedure Replace_Element (Container : in out List;
                           Position  : in     Cursor;
                           New_item  : in     Element_Type)
   with Pre  => (not Tampering_With_Elements_Prohibited (Container)
                   or else raise Program_Error) and then
                (Position /= No_Element
                   or else raise Constraint_Error) and then
                (Has_Element (Container, Position) 
                   or else raise Program_Error);
81/5
{AI95-00302-03} {AI05-0264-1} {AI12-0112-1} {AI12-0196-1} Replace_Element assigns the value New_Item to the element designated by Position. For the purposes of determining whether the parameters overlap in a call to Replace_Element, the Container parameter is not considered to overlap with any object [(including itself)].
82/5
procedure Query_Element
  (Position : in Cursor;
   Process  : not null access procedure (Element : in Element_Type))
   with Pre  => Position /= No_Element or else raise Constraint_Error,
        Global => in all;
83/5
{AI95-00302-03} {AI05-0021-1} {AI05-0265-1} {AI12-0112-1} Query_Element calls Process.all with the element designated by Position as the argument. Tampering with the elements of the list that contains the element designated by Position is prohibited during the execution of the call on Process.all. Any exception raised by Process.all is propagated.
83.1/5
procedure Query_Element
  (Container : in List;
   Position  : in Cursor;
   Process   : not null access procedure (Element : in Element_Type))
   with Pre  => (Position /= No_Element
                    or else raise Constraint_Error) and then
                 (Has_Element (Container, Position)
                    or else raise Program_Error);
83.2/5
{AI12-0112-1} Query_Element calls Process.all with the element designated by Position as the argument. Tampering with the elements of Container is prohibited during the execution of the call on Process.all. Any exception raised by Process.all is propagated.
84/5
procedure Update_Element
  (Container : in out List;
   Position  : in     Cursor;
   Process   : not null access procedure
                   (Element : in out Element_Type))
   with Pre  => (Position /= No_Element 
                    or else raise Constraint_Error) and then
                 (Has_Element (Container, Position) 
                    or else raise Program_Error);
85/5
{AI95-00302-03} {AI05-0264-1} {AI05-0265-1} {AI12-0112-1} Update_Element calls Process.all with the element designated by Position as the argument. Tampering with the elements of Container is prohibited during the execution of the call on Process.all. Any exception raised by Process.all is propagated.
86/2
If Element_Type is unconstrained and definite, then the actual Element parameter of Process.all shall be unconstrained.
86.a/2
Ramification: This means that the elements cannot be directly allocated from the heap; it must be possible to change the discriminants of the element in place. 
86.1/5
{AI12-0112-1} type Constant_Reference_Type
      (Element : not null access constant Element_Type) is private
   with Implicit_Dereference => Element,
        Nonblocking, Global => in out synchronized,
        Default_Initial_Condition => (raise Program_Error);
86.2/5
{AI12-0112-1} type Reference_Type (Element : not null access Element_Type) is private
   with Implicit_Dereference => Element,
        Nonblocking, Global => in out synchronized,
        Default_Initial_Condition => (raise Program_Error);
86.3/3
{AI05-0212-1} The types Constant_Reference_Type and Reference_Type need finalization.
86.4/5
This paragraph was deleted.{AI12-0112-1}
86.b/3
Reason: It is expected that Reference_Type (and Constant_Reference_Type) will be a controlled type, for which finalization will have some action to terminate the tampering check for the associated container. If the object is created by default, however, there is no associated container. Since this is useless, and supporting this case would take extra work, we define it to raise an exception. 
86.5/5
{AI12-0112-1} function Constant_Reference (Container : aliased in List;
                             Position  : in Cursor)
   return Constant_Reference_Type
   with Pre  => (Position /= No_Element or else
                    raise Constraint_Error) and then
                 (Has_Element (Container, Position) or else
                    raise Program_Error),
        Post   => Tampering_With_Cursors_Prohibited (Container),
        Nonblocking, Global => null, Use_Formal => null;
86.6/3
{AI05-0212-1} {AI05-0269-1} This function (combined with the Constant_Indexing and Implicit_Dereference aspects) provides a convenient way to gain read access to an individual element of a list given a cursor.
86.7/5
{AI05-0212-1} {AI05-0265-1} {AI12-0112-1} Constant_Reference returns an object whose discriminant is an access value that designates the element designated by Position. Tampering with the elements of Container is prohibited while the object returned by Constant_Reference exists and has not been finalized.
86.8/5
{AI12-0112-1} function Reference (Container : aliased in out List;
                    Position  : in Cursor)
   return Reference_Type
   with Pre  => (Position /= No_Element or else
                    raise Constraint_Error) and then
                 (Has_Element (Container, Position) or else 
                    raise Program_Error),
        Post   => Tampering_With_Cursors_Prohibited (Container),
        Nonblocking, Global => null, Use_Formal => null;
86.9/3
{AI05-0212-1} {AI05-0269-1} This function (combined with the Variable_Indexing and Implicit_Dereference aspects) provides a convenient way to gain read and write access to an individual element of a list given a cursor.
86.10/5
{AI05-0212-1} {AI05-0265-1} {AI12-0112-1} Reference returns an object whose discriminant is an access value that designates the element designated by Position. Tampering with the elements of Container is prohibited while the object returned by Reference exists and has not been finalized.
86.11/5
{AI12-0112-1} procedure Assign (Target : in out List; Source : in List)
   with Pre  => not Tampering_With_Cursors_Prohibited (Target)
                   or else raise Program_Error,
        Post => Length (Source) = Length (Target);
86.12/3
{AI05-0001-1} {AI05-0248-1} If Target denotes the same object as Source, the operation has no effect. Otherwise, the elements of Source are copied to Target as for an assignment_statement assigning Source to Target. 
86.c/3
Discussion: {AI05-0005-1} This routine exists for compatibility with the bounded list container. For an unbounded list, Assign(A, B) and A := B behave identically. For a bounded list, := will raise an exception if the container capacities are different, while Assign will not raise an exception if there is enough room in the target. 
86.13/5
{AI12-0112-1} function Copy (Source : List)
   return List
   with Post => 
           Length (Copy'Result) = Length (Source) and then
           not Tampering_With_Elements_Prohibited (Copy'Result) and then
           not Tampering_With_Cursors_Prohibited (Copy'Result);
86.14/3
{AI05-0001-1} Returns a list whose elements match the elements of Source.
87/5
{AI12-0112-1} procedure Move (Target : in out List;
                Source : in out List)
   with Pre  => (not Tampering_With_Cursors_Prohibited (Target)
                    or else raise Program_Error) and then
                (not Tampering_With_Cursors_Prohibited (Source)
                    or else raise Program_Error),
        Post => (if not Target'Has_Same_Storage (Source) then
                    Length (Target) = Length (Source'Old) and then
                    Length (Source) = 0);
88/3
{AI95-00302-03} {AI05-0001-1} {AI05-0248-1} {AI05-0262-1} If Target denotes the same object as Source, then the operation has no effect. Otherwise, the operation is equivalent to Assign (Target, Source) followed by Clear (Source).
89/5
procedure Insert (Container : in out List;
                  Before    : in     Cursor;
                  New_Item  : in     Element_Type;
                  Count     : in     Count_Type := 1)
   with Pre  => (not Tampering_With_Cursors_Prohibited (Container)
                   or else raise Program_Error) and then
                (Before = No_Element or else
                 Has_Element (Container, Before)
                   or else raise Program_Error) and then
                (Length (Container) <= Count_Type'Last - Count
                   or else raise Constraint_Error),
        Post => Length (Container)'Old + Count = Length (Container);
90/5
{AI95-00302-03} {AI12-0112-1} Insert inserts Count copies of New_Item prior to the element designated by Before. If Before equals No_Element, the new elements are inserted after the last node (if any). Any exception raised during allocation of internal storage is propagated, and Container is not modified.
90.a/2
Ramification: The check on Before checks that the cursor does not belong to some other Container. This check implies that a reference to the container is included in the cursor value. This wording is not meant to require detection of dangling cursors; such cursors are defined to be invalid, which means that execution is erroneous, and any result is allowed (including not raising an exception). 
91/5
procedure Insert (Container : in out List;
                  Before    : in     Cursor;
                  New_Item  : in     Element_Type;
                  Position  :    out Cursor;
                  Count     : in     Count_Type := 1)
   with Pre  => (not Tampering_With_Cursors_Prohibited (Container)
                   or else raise Program_Error) and then
                (Before = No_Element or else
                 Has_Element (Container, Before)
                   or else raise Program_Error) and then
                (Length (Container) <= Count_Type'Last - Count
                   or else raise Constraint_Error),
        Post => Length (Container)'Old + Count = Length (Container)
                and then Has_Element (Container, Position);
92/5
{AI95-00302-03} {AI05-0257-1} {AI12-0112-1} Insert allocates Count copies of New_Item, and inserts them prior to the element designated by Before. If Before equals No_Element, the new elements are inserted after the last element (if any). Position designates the first newly-inserted element, or if Count equals 0, then Position is assigned the value of Before. Any exception raised during allocation of internal storage is propagated, and Container is not modified.
93/5
procedure Insert (Container : in out List;
                  Before    : in     Cursor;
                  Position  :    out Cursor;
                  Count     : in     Count_Type := 1)
   with Pre  => (not Tampering_With_Cursors_Prohibited (Container)
                   or else raise Program_Error) and then
                (Before = No_Element or else
                 Has_Element (Container, Before)
                   or else raise Program_Error) and then
                (Length (Container) <= Count_Type'Last - Count
                   or else raise Constraint_Error),
        Post => Length (Container)'Old + Count = Length (Container)
                and then Has_Element (Container, Position);
94/5
{AI95-00302-03} {AI05-0257-1} {AI12-0112-1} Insert inserts Count new elements prior to the element designated by Before. If Before equals No_Element, the new elements are inserted after the last node (if any). The new elements are initialized by default (see 3.3.1). Position designates the first newly-inserted element, or if Count equals 0, then Position is assigned the value of Before. Any exception raised during allocation of internal storage is propagated, and Container is not modified.
95/5
{AI12-0112-1} procedure Prepend (Container : in out List;
                   New_Item  : in     Element_Type;
                   Count     : in     Count_Type := 1)
   with Pre  => (not Tampering_With_Cursors_Prohibited (Container)
                   or else raise Program_Error) and then
                (Length (Container) <= Count_Type'Last - Count
                   or else raise Constraint_Error),
        Post => Length (Container)'Old + Count = Length (Container);
96/2
{AI95-00302-03} Equivalent to Insert (Container, First (Container), New_Item, Count).
97/5
{AI12-0112-1} {AI12-0400-1} procedure Append (Container : in out List;
                  New_Item  : in     Element_Type;
                  Count     : in     Count_Type)
   with Pre  => (not Tampering_With_Cursors_Prohibited (Container)
                   or else raise Program_Error) and then
                (Length (Container) <= Count_Type'Last - Count
                   or else raise Constraint_Error),
        Post => Length (Container)'Old + Count = Length (Container);
98/2
{AI95-00302-03} Equivalent to Insert (Container, No_Element, New_Item, Count).
98.1/5
{AI12-0391-1} {AI12-0400-1} procedure Append (Container : in out List;
                  New_Item  : in     Element_Type)
   with Pre  => (not Tampering_With_Cursors_Prohibited (Container)
                   or else raise Program_Error) and then
                (Length (Container) <= Count_Type'Last - 1
                   or else raise Constraint_Error),
        Post => Length (Container)'Old + 1 = Length (Container);
98.2/5
{AI12-0391-1} Equivalent to Insert (Container, No_Element, New_Item, 1).
99/5
procedure Delete (Container : in out List;
                  Position  : in out Cursor;
                  Count     : in     Count_Type := 1)
   with Pre  => (not Tampering_With_Cursors_Prohibited (Container)
                   or else raise Program_Error) and then
                (Position /= No_Element
                   or else raise Constraint_Error) and then
                (Has_Element (Container, Position)
                   or else raise Program_Error),
        Post => Length (Container)'Old - Count <= Length (Container)
                and then Position = No_Element;
100/5
{AI95-00302-03} {AI05-0264-1} {AI12-0112-1} Delete removes (from Container) Count elements starting at the element designated by Position (or all of the elements starting at Position if there are fewer than Count elements starting at Position). Finally, Position is set to No_Element.
101/5
{AI12-0112-1} procedure Delete_First (Container : in out List;
                        Count     : in     Count_Type := 1)
   with Pre  => not Tampering_With_Cursors_Prohibited (Container)
                   or else raise Program_Error,
        Post => Length (Container)'Old - Count <= Length (Container);
102/3
{AI95-00302-03} {AI05-0021-1} If Length (Container) <= Count, then Delete_First is equivalent to Clear (Container). Otherwise, it removes the first Count nodes from Container.
103/5
{AI12-0112-1} procedure Delete_Last (Container : in out List;
                       Count     : in     Count_Type := 1)
   with Pre  => not Tampering_With_Cursors_Prohibited (Container)
                   or else raise Program_Error,
        Post => Length (Container)'Old - Count <= Length (Container);
104/3
{AI95-00302-03} {AI05-0264-1} If Length (Container) <= Count, then Delete_Last is equivalent to Clear (Container). Otherwise, it removes the last Count nodes from Container.
105/5
{AI12-0112-1} procedure Reverse_Elements (Container : in out List)
   with Pre  => not Tampering_With_Cursors_Prohibited (Container)
                   or else raise Program_Error;
106/2
{AI95-00302-03} Reorders the elements of Container in reverse order.
106.a/2
Discussion: Unlike the similar routine for a vector, elements should not be copied; rather, the nodes should be exchanged. Cursors are expected to reference the same elements afterwards.
107/5
procedure Swap (Container : in out List;
                I, J      : in     Cursor)
   with Pre  => (not Tampering_With_Elements_Prohibited (Container)
                   or else raise Program_Error) and then
                (I /= No_Element or else Constraint_Error) and then
                (J /= No_Element or else Constraint_Error) and then
                (Has_Element (Container, I)
                   or else raise Program_Error) and then
                (Has_Element (Container, J)
                   or else raise Program_Error);
108/5
{AI95-00302-03} {AI12-0112-1} Swap exchanges the values of the elements designated by I and J.
108.a/2
Ramification: After a call to Swap, I designates the element value previously designated by J, and J designates the element value previously designated by I. The cursors do not become ambiguous from this operation. 
108.b/2
To be honest: The implementation is not required to actually copy the elements if it can do the swap some other way. But it is allowed to copy the elements if needed. 
109/5
procedure Swap_Links (Container : in out List;
                      I, J      : in     Cursor)
   with Pre  => (not Tampering_With_Elements_Prohibited (Container)
                   or else raise Program_Error) and then
                (I /= No_Element or else Constraint_Error) and then
                (J /= No_Element or else Constraint_Error) and then
                (Has_Element (Container, I)
                   or else raise Program_Error) and then
                (Has_Element (Container, J)
                   or else raise Program_Error);
110/5
{AI95-00302-03} {AI12-0112-1} Swap_Links exchanges the nodes designated by I and J.
110.a/2
Ramification: Unlike Swap, this exchanges the nodes, not the elements. No copying is performed. I and J designate the same elements after this call as they did before it. This operation can provide better performance than Swap if the element size is large.
111/5
procedure Splice (Target   : in out List;
                  Before   : in     Cursor;
                  Source   : in out List)
   with Pre  => (not Tampering_With_Cursors_Prohibited (Target)
                   or else raise Program_Error) and then
                (not Tampering_With_Cursors_Prohibited (Source)
                   or else raise Program_Error) and then
                (Before = No_Element or else
                 Has_Element (Target, Before)
                   or else raise Program_Error) and then
                (Target'Has_Same_Storage (Source) or else
                 Length (Target) <= Count_Type'Last - Length (Source)
                   or else raise Constraint_Error),
        Post => (if not Target'Has_Same_Storage (Source) then
                   (declare
                      Result_Length : constant Count_Type :=
                         Length (Source)'Old + Length (Target)'Old;
                    begin
                      Length (Source) = 0 and then
                      Length (Target) = Result_Length));
112/5
{AI95-00302-03} {AI12-0112-1} If Source denotes the same object as Target, the operation has no effect. Otherwise, Splice reorders elements such that they are removed from Source and moved to Target, immediately prior to Before. If Before equals No_Element, the nodes of Source are spliced after the last node of Target.
113/5
procedure Splice (Target   : in out List;
                  Before   : in     Cursor;
                  Source   : in out List;
                  Position : in out Cursor)
   with Pre  => (not Tampering_With_Cursors_Prohibited (Target)
                   or else raise Program_Error) and then
                (not Tampering_With_Cursors_Prohibited (Source)
                   or else raise Program_Error) and then
                (Position /= No_Element
                   or else raise Constraint_Error) and then
                (Has_Element (Source, Position)
                   or else raise Program_Error) and then
                (Before = No_Element or else
                 Has_Element (Target, Before)
                   or else raise Program_Error) and then
                (Target'Has_Same_Storage (Source) or else
                 Length (Target) <= Count_Type'Last - 1
                   or else raise Constraint_Error),
        Post => (declare
                   Org_Target_Length : constant Count_Type :=
                      Length (Target)'Old;
                   Org_Source_Length : constant Count_Type :=
                      Length (Source)'Old;
                 begin
                    (if Target'Has_Same_Storage (Source) then
                        Position = Position'Old
                     else Length (Source) = Org_Source_Length - 1 and then
                        Length (Target) = Org_Target_Length + 1 and then
                        Has_Element (Target, Position)));
114/5
{AI95-00302-03} {AI05-0264-1} {AI12-0112-1} If Source denotes the same object as Target, then there is no effect if Position equals Before, else the element designated by Position is moved immediately prior to Before, or, if Before equals No_Element, after the last element. Otherwise, the element designated by Position is removed from Source and moved to Target, immediately prior to Before, or, if Before equals No_Element, after the last element of Target. Position is updated to represent an element in Target. 
114.a/2
Ramification: If Source is the same as Target, and Position = Before, or Next(Position) = Before, Splice has no effect, as the element does not have to move to meet the postcondition.
115/5
procedure Splice (Container: in out List;
                  Before   : in     Cursor;
                  Position : in     Cursor)
   with Pre  => (not Tampering_With_Cursors_Prohibited (Container)
                   or else raise Program_Error) and then
                (Position /= No_Element
                   or else raise Constraint_Error) and then
                (Has_Element (Container, Position)
                   or else raise Program_Error) and then
                (Before = No_Element or else
                 Has_Element (Container, Before)
                   or else raise Program_Error),
        Post =>  Length (Container) = Length (Container)'Old;
116/5
{AI95-00302-03} {AI05-0264-1} {AI12-0112-1} If Position equals Before there is no effect. Otherwise, the element designated by Position is moved immediately prior to Before, or, if Before equals No_Element, after the last element.
117/5
{AI12-0112-1} function First (Container : List) return Cursor
   with Nonblocking, Global => null, Use_Formal => null,
        Post => (if not Is_Empty (Container)
                 then Has_Element (Container, First'Result)
                 else First'Result = No_Element);
118/2
{AI95-00302-03} If Container is empty, First returns No_Element. Otherwise, it returns a cursor that designates the first node in Container.
119/5
{AI12-0112-1} function First_Element (Container : List)
   return Element_Type
   with Pre => (not Is_Empty (Container) 
                   or else raise Constraint_Error);
120/2
{AI95-00302-03} Equivalent to Element (Container, First_Index (Container)).
121/5
{AI12-0112-1} function Last (Container : List) return Cursor
   with Nonblocking, Global => null, Use_Formal => null,
        Post => (if not Is_Empty (Container)
                 then Has_Element (Container, Last'Result)
                 else Last'Result = No_Element);
122/2
{AI95-00302-03} If Container is empty, Last returns No_Element. Otherwise, it returns a cursor that designates the last node in Container.
123/5
{AI12-0112-1} function Last_Element (Container : List)
   return Element_Type
   with Pre => (not Is_Empty (Container) 
                   or else raise Constraint_Error);
124/2
{AI95-00302-03} Equivalent to Element (Last (Container)).
125/5
{AI12-0112-1} function Next (Position : Cursor) return Cursor
   with Nonblocking, Global => in all, Use_Formal => null,
        Post => (if Position = No_Element then Next'Result = No_Element);
126/2
{AI95-00302-03} If Position equals No_Element or designates the last element of the container, then Next returns the value No_Element. Otherwise, it returns a cursor that designates the successor of the element designated by Position.
126.1/5
function Next (Container : List;
               Position  : Cursor) return Cursor
   with Nonblocking, Global => null, Use_Formal => null,
        Pre  => Position = No_Element or else
                Has_Element (Container, Position)
                   or else raise Program_Error,
        Post => (if Position = No_Element then Next'Result = No_Element
                 elsif Next'Result = No_Element then
                   Position = Last (Container)
                 else Has_Element (Container, Next'Result));
126.2/5
{AI12-0112-1} Returns a cursor designating the successor of the element designated by Position in Container.
127/5
{AI12-0112-1} function Previous (Position : Cursor) return Cursor
   with Nonblocking, Global => in all, Use_Formal => null,
        Post => (if Position = No_Element then 
                   Previous'Result = No_Element);
128/2
{AI95-00302-03} If Position equals No_Element or designates the first element of the container, then Previous returns the value No_Element. Otherwise, it returns a cursor that designates the predecessor of the element designated by Position.
128.1/5
function Previous (Container : List;
                   Position : Cursor) return Cursor
   with Nonblocking, Global => null, Use_Formal => null,
        Pre  => Position = No_Element or else
                Has_Element (Container, Position)
                   or else raise Program_Error,
        Post => (if Position = No_Element then 
                   Previous'Result = No_Element
                 elsif Previous'Result = No_Element then
                   Position = First (Container)
                 else Has_Element (Container, Previous'Result));
128.2/5
{AI12-0112-1} Returns a cursor designating the predecessor of the element designated by Position in Container, if any.
129/5
{AI12-0112-1} procedure Next (Position : in out Cursor)
   with Nonblocking, Global => in all, Use_Formal => null;
130/2
{AI95-00302-03} Equivalent to Position := Next (Position).
130.1/5
procedure Next (Container : in     List;
                Position  : in out Cursor)
   with Nonblocking, Global => null, Use_Formal => null,
        Pre  => Position = No_Element or else
                Has_Element (Container, Position)
                   or else raise Program_Error,
        Post => (if Position /= No_Element
                 then Has_Element (Container, Position));
130.2/5
{AI12-0112-1} Equivalent to Position := Next (Container, Position).
131/5
{AI12-0112-1} procedure Previous (Position : in out Cursor)
   with Nonblocking, Global => in all, Use_Formal => null;
132/2
{AI95-00302-03} Equivalent to Position := Previous (Position).
132.1/5
procedure Previous (Container : in     List;
                    Position  : in out Cursor)
   with Nonblocking, Global => null, Use_Formal => null,
        Pre  => Position = No_Element or else
                Has_Element (Container, Position)
                   or else raise Program_Error,
        Post => (if Position /= No_Element
                 then Has_Element (Container, Position));
132.2/5
{AI12-0112-1} Equivalent to Position := Previous (Container, Position).
133/5
function Find (Container : List;
               Item      : Element_Type;
               Position  : Cursor := No_Element)
   return Cursor
   with Pre  => Position = No_Element or else
                Has_Element (Container, Position)
                   or else raise Program_Error,
        Post => (if Find'Result /= No_Element
                 then Has_Element (Container, Find'Result));
134/5
{AI95-00302-03} {AI12-0112-1} Find searches the elements of Container for an element equal to Item (using the generic formal equality operator). The search starts at the element designated by Position, or at the first element if Position equals No_Element. It proceeds towards Last (Container). If no equal element is found, then Find returns No_Element. Otherwise, it returns a cursor designating the first equal element encountered.
135/5
function Reverse_Find (Container : List;
                       Item      : Element_Type;
                       Position  : Cursor := No_Element)
   return Cursor
   with Pre  => Position = No_Element or else
                Has_Element (Container, Position)
                   or else raise Program_Error,
        Post => (if Reverse_Find'Result /= No_Element
                 then Has_Element (Container, Reverse_Find'Result));
136/5
{AI95-00302-03} {AI12-0112-1} Find searches the elements of Container for an element equal to Item (using the generic formal equality operator). The search starts at the element designated by Position, or at the last element if Position equals No_Element. It proceeds towards First (Container). If no equal element is found, then Reverse_Find returns No_Element. Otherwise, it returns a cursor designating the first equal element encountered.
137/2
function Contains (Container : List;
                   Item      : Element_Type) return Boolean;
138/2
{AI95-00302-03} Equivalent to Find (Container, Item) /= No_Element.
Paragraphs 139 and 140 were moved above. 
141/5
{AI12-0112-1} procedure Iterate
  (Container : in List;
   Process   : not null access procedure (Position : in Cursor))
   with Allows_Exit;
142/3
{AI95-00302-03} {AI05-0265-1} Iterate calls Process.all with a cursor that designates each node in Container, starting with the first node and moving the cursor as per the Next function. Tampering with the cursors of Container is prohibited during the execution of a call on Process.all. Any exception raised by Process.all is propagated.
142.a/2
Implementation Note: The purpose of the tamper with cursors check is to prevent erroneous execution from the Position parameter of Process.all becoming invalid. This check takes place when the operations that tamper with the cursors of the container are called. The check cannot be made later (say in the body of Iterate), because that could cause the Position cursor to be invalid and potentially cause execution to become erroneous -- defeating the purpose of the check.
142.b/2
See Iterate for vectors (A.18.2) for a suggested implementation of the check. 
143/5
{AI12-0112-1} procedure Reverse_Iterate
  (Container : in List;
   Process   : not null access procedure (Position : in Cursor))
   with Allows_Exit;
144/3
{AI95-00302-03} {AI05-0212-1} Iterates over the nodes in Container as per procedure Iterate, except that elements are traversed in reverse order, starting with the last node and moving the cursor as per the Previous function.
144.1/5
{AI12-0112-1} {AI12-0266-1} function Iterate (Container : in List)
   return List_Iterator_Interfaces.Parallel_Reversible_Iterator'Class
   with Post   => Tampering_With_Cursors_Prohibited (Container);
144.2/5
{AI05-0212-1} {AI05-0265-1} {AI05-0269-1} {AI12-0266-1} Iterate returns an iterator object (see 5.5.1) that will generate a value for a loop parameter (see 5.5.2) designating each node in Container, starting with the first node and moving the cursor as per the Next function when used as a forward iterator, and starting with the last node and moving the cursor as per the Previous function when used as a reverse iterator, and processing all nodes concurrently when used as a parallel iterator. Tampering with the cursors of Container is prohibited while the iterator object exists (in particular, in the sequence_of_statements of the loop_statement whose iterator_specification denotes this object). The iterator object needs finalization.
144.3/5
function Iterate (Container : in List; Start : in Cursor)
   return List_Iterator_Interfaces.Reversible_Iterator'Class
   with Pre    => (Start /= No_Element
                        or else raise Constraint_Error) and then
                     (Has_Element (Container, Start)
                        or else raise Program_Error),
        Post   => Tampering_With_Cursors_Prohibited (Container);
144.4/5
{AI05-0212-1} {AI05-0262-1} {AI05-0265-1} {AI05-0269-1} {AI12-0112-1} Iterate returns a reversible iterator object (see 5.5.1) that will generate a value for a loop parameter (see 5.5.2) designating each node in Container, starting with the node designated by Start and moving the cursor as per the Next function when used as a forward iterator, or moving the cursor as per the Previous function when used as a reverse iterator. Tampering with the cursors of Container is prohibited while the iterator object exists (in particular, in the sequence_of_statements of the loop_statement whose iterator_specification denotes this object). The iterator object needs finalization.
144.a/3
Discussion: Exits are allowed from the loops created using the iterator objects. In particular, to stop the iteration at a particular cursor, just add
144.b/3
exit when Cur = Stop;
144.c/3
in the body of the loop (assuming that Cur is the loop parameter and Stop is the cursor that you want to stop at). 
145/3
 {AI05-0044-1} {AI05-0262-1} The actual function for the generic formal function "<" of Generic_Sorting is expected to return the same value each time it is called with a particular pair of element values. It should define a strict weak ordering relationship (see A.18); it should not modify Container. If the actual for "<" behaves in some other manner, the behavior of the subprograms of Generic_Sorting are unspecified. The number of times the subprograms of Generic_Sorting call "<" is unspecified.
146/2
function Is_Sorted (Container : List) return Boolean;
147/2
{AI95-00302-03} Returns True if the elements are sorted smallest first as determined by the generic formal "<" operator; otherwise, Is_Sorted returns False. Any exception raised during evaluation of "<" is propagated.
148/5
{AI12-0112-1} procedure Sort (Container : in out List)
   with Pre  => not Tampering_With_Cursors_Prohibited (Container)
                    or else raise Program_Error;
149/2
{AI95-00302-03} Reorders the nodes of Container such that the elements are sorted smallest first as determined by the generic formal "<" operator provided. The sort is stable. Any exception raised during evaluation of "<" is propagated.
149.a/2
Ramification: Unlike array sorts, we do require stable sorts here. That's because algorithms in the merge sort family (as described by Knuth) can be both fast and stable. Such sorts use the extra memory as offered by the links to provide better performance.
149.b/2
Note that list sorts never copy elements; it is the nodes, not the elements, that are reordered. 
150/5
procedure Merge (Target  : in out List;
                 Source  : in out List)
   with Pre  => (not Tampering_With_Cursors_Prohibited (Target)
                   or else raise Program_Error) and then
                (not Tampering_With_Elements_Prohibited (Source)
                   or else raise Program_Error) and then
                (Length (Target) <= Count_Type'Last - Length (Source)
                   or else raise Constraint_Error) and then
                ((Length (Source) = 0 or else
                   not Target'Has_Same_Storage (Source))
                   or else raise Constraint_Error),
        Post => (declare
                   Result_Length : constant Count_Type :=
                      Length (Source)'Old + Length (Target)'Old;
                 begin
                   (Length (Source) = 0 and then
                    Length (Target) = Result_Length));
151/5
{AI95-00302-03} {AI05-0021-1} {AI12-0112-1} Merge removes elements from Source and inserts them into Target; afterwards, Target contains the union of the elements that were initially in Source and Target; Source is left empty. If Target and Source are initially sorted smallest first, then Target is ordered smallest first as determined by the generic formal "<" operator; otherwise, the order of elements in Target is unspecified. Any exception raised during evaluation of "<" is propagated.
151.a/2
Ramification: It is a bounded error if either of the lists is unsorted, see below. The bounded error can be recovered by sorting Target after the merge call, or the lists can be pretested with Is_Sorted. 
151.1/5
   {AI12-0111-1} The nested package Doubly_Linked_Lists.Stable provides a type Stable.List that represents a stable list, which is one that cannot grow and shrink. Such a list can be created by calling the Copy function, or by establishing a stabilized view of an ordinary list.
151.2/5
   {AI12-0111-1} The subprograms of package Containers.Doubly_Linked_Lists that have a parameter or result of type List are included in the nested package Stable with the same specification, except that the following are omitted:
151.3/5
Tampering_With_Cursors_Prohibited, Tampering_With_Elements_Prohibited, Assign, Move, Insert, Append, Prepend, Clear, Delete, Delete_First, Delete_Last, Splice, Swap_Links, and Reverse_Elements 
151.a.1/5
Ramification: The names List and Cursor mean the types declared in the nested package in these subprogram specifications.
151.a.2/5
Reason: The omitted routines are those that tamper with cursors or elements (or test that state). The model is that it is impossible to tamper with cursors or elements of a stable view since no such operations are included. Thus tampering checks are not needed for a stable view, and we omit the operations associated with those checks.
151.a.3/5
The Generic_Sorting generic is omitted entirely, as only function Is_Sorting does not tamper with cursors. It isn't useful enough by itself to include. 
151.4/5
   {AI12-0111-1} The operations of this package are equivalent to those for ordinary lists, except that the calls to Tampering_With_Cursors_Prohibited and Tampering_With_Elements_Prohibited that occur in preconditions are replaced by False, and any that occur in postconditions are replaced by True.
151.5/5
   {AI12-0111-1} {AI12-0439-1} If a stable list is declared with the Base discriminant designating a pre-existing ordinary list, the stable list represents a stabilized view of the underlying ordinary list, and any operation on the stable list is reflected on the underlying ordinary list. While a stabilized view exists, any operation that tampers with elements performed on the underlying list is prohibited. The finalization of a stable list that provides such a view removes this restriction on the underlying ordinary list [(though some other restriction can exist due to other concurrent iterations or stabilized views)].
151.6/5
   {AI12-0111-1} {AI12-0438-1} If a stable list is declared without specifying Base, the object is necessarily initialized. The initializing expression of the stable list, [typically a call on Copy], determines the Length of the list. The Length of a stable list never changes after initialization.
151.b/5
Proof: {AI12-0438-1} Initialization is required as the type is indefinite, see 3.3.1.

Bounded (Run-Time) Errors

152/2
 {AI95-00302-03} Calling Merge in an instance of Generic_Sorting with either Source or Target not ordered smallest first using the provided generic formal "<" operator is a bounded error. Either Program_Error is raised after Target is updated as described for Merge, or the operation works as defined.
152.1/3
   {AI05-0022-1} {AI05-0248-1} It is a bounded error for the actual function associated with a generic formal subprogram, when called as part of an operation of this package, to tamper with elements of any List parameter of the operation. Either Program_Error is raised, or the operation works as defined on the value of the List either prior to, or subsequent to, some or all of the modifications to the List.
152.2/3
   {AI05-0027-1} It is a bounded error to call any subprogram declared in the visible part of Containers.Doubly_Linked_Lists when the associated container has been finalized. If the operation takes Container as an in out parameter, then it raises Constraint_Error or Program_Error. Otherwise, the operation either proceeds as it would for an empty container, or it raises Constraint_Error or Program_Error.

Erroneous Execution

153/2
 {AI95-00302-03} A Cursor value is invalid if any of the following have occurred since it was created:
154/2
The list that contains the element it designates has been finalized;
154.1/3
{AI05-0160-1} The list that contains the element it designates has been used as the Target of a call to Assign, or as the target of an assignment_statement;
155/2
[The list that contains the element it designates has been used as the Source or Target of a call to Move;] or 
155.a/3
Proof: {AI05-0001-1} Move has been reworded in terms of Assign and Clear, which are covered by other bullets, so this text is redundant. 
156/3
{AI05-0160-1} {AI05-0262-1} The element it designates has been removed from the list that previously contained the element. 
156.a/3
To be honest: {AI05-0160-1} The cursor modified by the four parameter Splice is not invalid, even though the element it designates has been removed from the source list, because that cursor has been modified to designate that element in the target list – the cursor no longer designates an element in the source list. 
156.b/3
Ramification: {AI05-0160-1} This can happen directly via calls to Delete, Delete_Last, Clear, Splice with a Source parameter, and Merge; and indirectly via calls to Delete_First, Assign, and Move. 
157/2
 {AI95-00302-03} The result of "=" or Has_Element is unspecified if it is called with an invalid cursor parameter. Execution is erroneous if any other subprogram declared in Containers.Doubly_Linked_Lists is called with an invalid cursor parameter.
157.a/2
Discussion: The list above is intended to be exhaustive. In other cases, a cursor value continues to designate its original element. For instance, cursor values survive the insertion and deletion of other nodes.
157.b/2
While it is possible to check for these cases, in many cases the overhead necessary to make the check is substantial in time or space. Implementations are encouraged to check for as many of these cases as possible and raise Program_Error if detected. 
157.1/3
   {AI05-0212-1} Execution is erroneous if the list associated with the result of a call to Reference or Constant_Reference is finalized before the result object returned by the call to Reference or Constant_Reference is finalized.
157.c/3
Reason: Each object of Reference_Type and Constant_Reference_Type probably contains some reference to the originating container. If that container is prematurely finalized (which is only possible via Unchecked_Deallocation, as accessibility checks prevent passing a container to Reference that will not live as long as the result), the finalization of the object of Reference_Type will try to access a nonexistent object. This is a normal case of a dangling pointer created by Unchecked_Deallocation; we have to explicitly mention it here as the pointer in question is not visible in the specification of the type. (This is the same reason we have to say this for invalid cursors.) 

Implementation Requirements

158/5
 {AI95-00302-03} {AI12-0437-1} No storage associated with a doubly-linked list object shall be lost upon assignment or scope exit.
159/3
 {AI95-00302-03} {AI05-0262-1} The execution of an assignment_statement for a list shall have the effect of copying the elements from the source list object to the target list object and changing the length of the target object to that of the source object.
159.a/3
Implementation Note: {AI05-0298-1} An assignment of a List is a “deep” copy; that is the elements are copied as well as the data structures. We say “effect of” in order to allow the implementation to avoid copying elements immediately if it wishes. For instance, an implementation that avoided copying until one of the containers is modified would be allowed. (Note that this implementation would require care, see A.18.2 for more.)

Implementation Advice

160/2
 {AI95-00302-03} Containers.Doubly_Linked_Lists should be implemented similarly to a linked list. In particular, if N is the length of a list, then the worst-case time complexity of Element, Insert with Count=1, and Delete with Count=1 should be O(log N). 
160.a/2
Implementation Advice: The worst-case time complexity of Element, Insert with Count=1, and Delete with Count=1 for Containers.Doubly_Linked_Lists should be O(log N).
160.b/2
Reason: We do not mean to overly constrain implementation strategies here. However, it is important for portability that the performance of large containers has roughly the same factors on different implementations. If a program is moved to an implementation that takes O(N) time to access elements, that program could be unusable when the lists are large. We allow O(log N) access because the proportionality constant and caching effects are likely to be larger than the log factor, and we don't want to discourage innovative implementations. 
161/2
 {AI95-00302-03} The worst-case time complexity of a call on procedure Sort of an instance of Containers.Doubly_Linked_Lists.Generic_Sorting should be O(N**2), and the average time complexity should be better than O(N**2).
161.a/2
Implementation Advice: A call on procedure Sort of an instance of Containers.Doubly_Linked_Lists.Generic_Sorting should have an average time complexity better than O(N**2) and worst case no worse than O(N**2).
161.b/2
Ramification: In other words, we're requiring the use of a better than O(N**2) sorting algorithm, such as Quicksort. No bubble sorts allowed! 
162/2
 {AI95-00302-03} Move should not copy elements, and should minimize copying of internal data structures. 
162.a/2
Implementation Advice: Containers.Doubly_Linked_Lists.Move should not copy elements, and should minimize copying of internal data structures.
162.b/2
Implementation Note: Usually that can be accomplished simply by moving the pointer(s) to the internal data structures from the Source container to the Target container. 
163/2
 {AI95-00302-03} If an exception is propagated from a list operation, no storage should be lost, nor any elements removed from a list unless specified by the operation. 
163.a/2
Implementation Advice: If an exception is propagated from a list operation, no storage should be lost, nor any elements removed from a list unless specified by the operation.
163.b/2
Reason: This is important so that programs can recover from errors. But we don't want to require heroic efforts, so we just require documentation of cases where this can't be accomplished.
164/5
NOTE   {AI95-00302-03} {AI12-0442-1} Sorting a list never copies elements, and is a stable sort (equal elements remain in the original order). This is different than sorting an array or vector, which will often copy elements, and hence is probably not a stable sort. 

Extensions to Ada 95

164.a/2
{AI95-00302-03} The generic package Containers.Doubly_Linked_Lists is new. 

Inconsistencies With Ada 2005

164.b/3
{AI05-0248-1} {AI05-0257-1} Correction: The Insert versions that return a Position parameter are now defined to return Position = Before if Count = 0. This was unspecified for Ada 2005; so this will only be inconsistent if an implementation did something else and a program depended on that something else — this should be very rare. 

Incompatibilities With Ada 2005

164.c/3
{AI05-0001-1} Subprograms Assign and Copy are added to Containers.Doubly_Linked_Lists. If an instance of Containers.Doubly_Linked_Lists is referenced in a use_clause, and an entity E with the same defining_identifier as a new entity in Containers.Doubly_Linked_Lists is defined in a package that is also referenced in a use_clause, the entity E may no longer be use-visible, resulting in errors. This should be rare and is easily fixed if it does occur. 

Extensions to Ada 2005

164.d/3
{AI05-0212-1} Added iterator, reference, and indexing support to make list containers more convenient to use. 

Wording Changes from Ada 2005

164.e/3
{AI05-0001-1} Generalized the definition of Move. Specified which elements are read/written by stream attributes.
164.f/3
{AI05-0022-1} Correction: Added a Bounded (Run-Time) Error to cover tampering by generic actual subprograms.
164.g/3
{AI05-0027-1} Correction: Added a Bounded (Run-Time) Error to cover access to finalized list containers.
164.h/3
{AI05-0044-1} Correction: Redefined "<" actuals to require a strict weak ordering; the old definition allowed indeterminant comparisons that would not have worked in a container.
164.i/3
{AI05-0084-1} Correction: Added a pragma Remote_Types so that containers can be used in distributed programs.
164.j/3
{AI05-0160-1} Correction: Revised the definition of invalid cursors to cover missing (and new) cases.
164.k/3
{AI05-0257-1} Correction: Added missing wording to describe the Position after Inserting 0 elements.
164.l/3
{AI05-0265-1} Correction: Defined when a container prohibits tampering in order to more clearly define where the check is made and the exception raised.

Inconsistencies With Ada 2012

164.m/5
{AI12-0111-1} Correction: Tampering with elements is now defined to be equivalent to tampering with cursors for ordinary containers. If a program requires tampering detection to work, it might fail in Ada 2022. Needless to say, this shouldn't happen outside of test programs. See Inconsistencies With Ada 2012 in A.18.2 for more details. 

Incompatibilities With Ada 2012

164.n/5
{AI12-0111-1} {AI12-0112-1} {AI12-0339-1} {AI12-0391-1} A number of new subprograms, types, and even a nested package were added to Containers.Doubly_Linked_Lists to better support contracts and stable views. Therefore, a use clause conflict is possible; see the introduction of Annex A for more on this topic. 

Extensions to Ada 2012

164.o/5
{AI12-0196-1} Replace_Element is now defined such that it can be used concurrently so long as it operates on different elements. This allows some container operations to be used in parallel without separate synchronization.
164.p/5
{AI12-0212-1} {AI12-0391-1} Lists now support positional container aggregates, so aggregate syntax can be used to create Lists.
164.q/5
{AI12-0266-1} The iterator for the entire container now can return a parallel iterator which can be used to process the container in parallel. 

Wording Changes from Ada 2012

164.r/4
{AI12-0110-1} Corrigendum: Clarified that tampering checks precede all other checks made by a subprogram (but come after those associated with the call).
164.s/5
{AI12-0112-1} Added contracts to this container. This includes describing some of the semantics with pre- and postconditions, rather than English text. Note that the preconditions can be Suppressed (see 11.5).
164.t/5
{AI12-0400-1} Correction: Split the Append routine into two routines rather than having a single routine with a default parameter, in order that a routine with the appropriate profile for the Aggregate aspect exists. This change should not change the behavior of any existing code. 

Contents   Index   References   Search   Previous   Next 
Ada-Europe Ada 2005 and 2012 Editions sponsored in part by Ada-Europe