OSDN Git Service

Daily bump.
[pf3gnuchains/gcc-fork.git] / gcc / ada / a-ciormu.adb
index 9e24d3e..4ee897d 100644 (file)
@@ -2,16 +2,11 @@
 --                                                                          --
 --                         GNAT LIBRARY COMPONENTS                          --
 --                                                                          --
---                      A D A . C O N T A I N E R S .                       --
---         I N D E F I N I T E _ O R D E R E D _ M U L T I S E T S          --
+--               ADA.CONTAINERS.INDEFINITE_ORDERED_MULTISETS                --
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 2004-2005 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 --
--- apply solely to the  contents of the part following the private keyword. --
+--          Copyright (C) 2004-2007, Free Software Foundation, Inc.         --
 --                                                                          --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -87,6 +82,11 @@ package body Ada.Containers.Indefinite_Ordered_Multisets is
 
    procedure Free (X : in out Node_Access);
 
+   procedure Insert_Sans_Hint
+     (Tree     : in out Tree_Type;
+      New_Item : Element_Type;
+      Node     : out Node_Access);
+
    procedure Insert_With_Hint
      (Dst_Tree : in out Tree_Type;
       Dst_Hint : Node_Access;
@@ -157,16 +157,60 @@ package body Ada.Containers.Indefinite_Ordered_Multisets is
 
    function "<" (Left, Right : Cursor) return Boolean is
    begin
+      if Left.Node = null then
+         raise Constraint_Error with "Left cursor equals No_Element";
+      end if;
+
+      if Right.Node = null then
+         raise Constraint_Error with "Right cursor equals No_Element";
+      end if;
+
+      if Left.Node.Element = null then
+         raise Program_Error with "Left cursor is bad";
+      end if;
+
+      if Right.Node.Element = null then
+         raise Program_Error with "Right cursor is bad";
+      end if;
+
+      pragma Assert (Vet (Left.Container.Tree, Left.Node),
+                     "bad Left cursor in ""<""");
+
+      pragma Assert (Vet (Right.Container.Tree, Right.Node),
+                     "bad Right cursor in ""<""");
+
       return Left.Node.Element.all < Right.Node.Element.all;
    end "<";
 
    function "<" (Left : Cursor; Right : Element_Type) return Boolean is
    begin
+      if Left.Node = null then
+         raise Constraint_Error with "Left cursor equals No_Element";
+      end if;
+
+      if Left.Node.Element = null then
+         raise Program_Error with "Left cursor is bad";
+      end if;
+
+      pragma Assert (Vet (Left.Container.Tree, Left.Node),
+                     "bad Left cursor in ""<""");
+
       return Left.Node.Element.all < Right;
    end "<";
 
    function "<" (Left : Element_Type; Right : Cursor) return Boolean is
    begin
+      if Right.Node = null then
+         raise Constraint_Error with "Right cursor equals No_Element";
+      end if;
+
+      if Right.Node.Element = null then
+         raise Program_Error with "Right cursor is bad";
+      end if;
+
+      pragma Assert (Vet (Right.Container.Tree, Right.Node),
+                     "bad Right cursor in ""<""");
+
       return Left < Right.Node.Element.all;
    end "<";
 
@@ -183,20 +227,64 @@ package body Ada.Containers.Indefinite_Ordered_Multisets is
    -- ">" --
    ---------
 
-   function ">" (Left : Cursor; Right : Element_Type) return Boolean is
-   begin
-      return Right < Left.Node.Element.all;
-   end ">";
-
    function ">" (Left, Right : Cursor) return Boolean is
    begin
+      if Left.Node = null then
+         raise Constraint_Error with "Left cursor equals No_Element";
+      end if;
+
+      if Right.Node = null then
+         raise Constraint_Error with "Right cursor equals No_Element";
+      end if;
+
+      if Left.Node.Element = null then
+         raise Program_Error with "Left cursor is bad";
+      end if;
+
+      if Right.Node.Element = null then
+         raise Program_Error with "Right cursor is bad";
+      end if;
+
+      pragma Assert (Vet (Left.Container.Tree, Left.Node),
+                     "bad Left cursor in "">""");
+
+      pragma Assert (Vet (Right.Container.Tree, Right.Node),
+                     "bad Right cursor in "">""");
+
       --  L > R same as R < L
 
       return Right.Node.Element.all < Left.Node.Element.all;
    end ">";
 
+   function ">" (Left : Cursor; Right : Element_Type) return Boolean is
+   begin
+      if Left.Node = null then
+         raise Constraint_Error with "Left cursor equals No_Element";
+      end if;
+
+      if Left.Node.Element = null then
+         raise Program_Error with "Left cursor is bad";
+      end if;
+
+      pragma Assert (Vet (Left.Container.Tree, Left.Node),
+                     "bad Left cursor in "">""");
+
+      return Right < Left.Node.Element.all;
+   end ">";
+
    function ">" (Left : Element_Type; Right : Cursor) return Boolean is
    begin
+      if Right.Node = null then
+         raise Constraint_Error with "Right cursor equals No_Element";
+      end if;
+
+      if Right.Node.Element = null then
+         raise Program_Error with "Right cursor is bad";
+      end if;
+
+      pragma Assert (Vet (Right.Container.Tree, Right.Node),
+                     "bad Right cursor in "">""");
+
       return Right.Node.Element.all < Left;
    end ">";
 
@@ -290,7 +378,7 @@ package body Ada.Containers.Indefinite_Ordered_Multisets is
 
    begin
       if Node = Done then
-         raise Constraint_Error;
+         raise Constraint_Error with "attempt to delete element not in set";
       end if;
 
       loop
@@ -306,13 +394,20 @@ package body Ada.Containers.Indefinite_Ordered_Multisets is
    procedure Delete (Container : in out Set; Position : in out Cursor) is
    begin
       if Position.Node = null then
-         raise Constraint_Error;
+         raise Constraint_Error with "Position cursor equals No_Element";
+      end if;
+
+      if Position.Node.Element = null then
+         raise Program_Error with "Position cursor is bad";
       end if;
 
       if Position.Container /= Container'Unrestricted_Access then
-         raise Program_Error;
+         raise Program_Error with "Position cursor designates wrong set";
       end if;
 
+      pragma Assert (Vet (Container.Tree, Position.Node),
+                     "bad cursor in Delete");
+
       Tree_Operations.Delete_Node_Sans_Free (Container.Tree, Position.Node);
       Free (Position.Node);
 
@@ -375,9 +470,35 @@ package body Ada.Containers.Indefinite_Ordered_Multisets is
 
    function Element (Position : Cursor) return Element_Type is
    begin
+      if Position.Node = null then
+         raise Constraint_Error with "Position cursor equals No_Element";
+      end if;
+
+      if Position.Node.Element = null then
+         raise Program_Error with "Position cursor is bad";
+      end if;
+
+      pragma Assert (Vet (Position.Container.Tree, Position.Node),
+                     "bad cursor in Element");
+
       return Position.Node.Element.all;
    end Element;
 
+   -------------------------
+   -- Equivalent_Elements --
+   -------------------------
+
+   function Equivalent_Elements (Left, Right : Element_Type) return Boolean is
+   begin
+      if Left < Right
+        or else Right < Left
+      then
+         return False;
+      else
+         return True;
+      end if;
+   end Equivalent_Elements;
+
    ---------------------
    -- Equivalent_Sets --
    ---------------------
@@ -420,6 +541,7 @@ package body Ada.Containers.Indefinite_Ordered_Multisets is
       Node : Node_Access := Element_Keys.Ceiling (Tree, Item);
       Done : constant Node_Access := Element_Keys.Upper_Bound (Tree, Item);
       X    : Node_Access;
+
    begin
       while Node /= Done loop
          X := Node;
@@ -464,6 +586,11 @@ package body Ada.Containers.Indefinite_Ordered_Multisets is
 
    function First_Element (Container : Set) return Element_Type is
    begin
+      if Container.Tree.First = null then
+         raise Constraint_Error with "set is empty";
+      end if;
+
+      pragma Assert (Container.Tree.First.Element /= null);
       return Container.Tree.First.Element.all;
    end First_Element;
 
@@ -490,11 +617,16 @@ package body Ada.Containers.Indefinite_Ordered_Multisets is
    procedure Free (X : in out Node_Access) is
       procedure Deallocate is
         new Ada.Unchecked_Deallocation (Node_Type, Node_Access);
+
    begin
       if X = null then
          return;
       end if;
 
+      X.Parent := X;
+      X.Left := X;
+      X.Right := X;
+
       begin
          Free_Element (X.Element);
       exception
@@ -538,34 +670,6 @@ package body Ada.Containers.Indefinite_Ordered_Multisets is
            Is_Less_Key_Node    => Is_Less_Key_Node,
            Is_Greater_Key_Node => Is_Greater_Key_Node);
 
-      ---------
-      -- "<" --
-      ---------
-
-      function "<" (Left : Key_Type; Right : Cursor) return Boolean is
-      begin
-         return Left < Right.Node.Element.all;
-      end "<";
-
-      function "<" (Left : Cursor; Right : Key_Type) return Boolean is
-      begin
-         return Right > Left.Node.Element.all;
-      end "<";
-
-      ---------
-      -- ">" --
-      ---------
-
-      function ">" (Left : Key_Type; Right : Cursor) return Boolean is
-      begin
-         return Left > Right.Node.Element.all;
-      end ">";
-
-      function ">" (Left : Cursor; Right : Key_Type) return Boolean is
-      begin
-         return Right < Left.Node.Element.all;
-      end ">";
-
       -------------
       -- Ceiling --
       -------------
@@ -603,7 +707,7 @@ package body Ada.Containers.Indefinite_Ordered_Multisets is
 
       begin
          if Node = Done then
-            raise Constraint_Error;
+            raise Constraint_Error with "attempt to delete key not in set";
          end if;
 
          loop
@@ -621,11 +725,32 @@ package body Ada.Containers.Indefinite_Ordered_Multisets is
       -------------
 
       function Element (Container : Set; Key : Key_Type) return Element_Type is
-         Node : constant Node_Access := Key_Keys.Find (Container.Tree, Key);
+         Node : constant Node_Access :=
+                  Key_Keys.Find (Container.Tree, Key);
+
       begin
+         if Node = null then
+            raise Constraint_Error with "key not in set";
+         end if;
+
          return Node.Element.all;
       end Element;
 
+      ---------------------
+      -- Equivalent_Keys --
+      ---------------------
+
+      function Equivalent_Keys (Left, Right : Key_Type) return Boolean is
+      begin
+         if Left < Right
+           or else Right < Left
+         then
+            return False;
+         else
+            return True;
+         end if;
+      end Equivalent_Keys;
+
       -------------
       -- Exclude --
       -------------
@@ -681,9 +806,10 @@ package body Ada.Containers.Indefinite_Ordered_Multisets is
 
       function Is_Greater_Key_Node
         (Left  : Key_Type;
-         Right : Node_Access) return Boolean is
+         Right : Node_Access) return Boolean
+      is
       begin
-         return Left > Right.Element.all;
+         return Key (Right.Element.all) < Left;
       end Is_Greater_Key_Node;
 
       ----------------------
@@ -692,9 +818,10 @@ package body Ada.Containers.Indefinite_Ordered_Multisets is
 
       function Is_Less_Key_Node
         (Left  : Key_Type;
-         Right : Node_Access) return Boolean is
+         Right : Node_Access) return Boolean
+      is
       begin
-         return Left < Right.Element.all;
+         return Left < Key (Right.Element.all);
       end Is_Less_Key_Node;
 
       -------------
@@ -746,6 +873,19 @@ package body Ada.Containers.Indefinite_Ordered_Multisets is
 
       function Key (Position : Cursor) return Key_Type is
       begin
+         if Position.Node = null then
+            raise Constraint_Error with
+              "Position cursor equals No_Element";
+         end if;
+
+         if Position.Node.Element = null then
+            raise Program_Error with
+              "Position cursor is bad";
+         end if;
+
+         pragma Assert (Vet (Position.Container.Tree, Position.Node),
+                        "bad cursor in Key");
+
          return Key (Position.Node.Element.all);
       end Key;
 
@@ -796,29 +936,37 @@ package body Ada.Containers.Indefinite_Ordered_Multisets is
          B := B - 1;
       end Reverse_Iterate;
 
-      -----------------------------------
-      -- Update_Element_Preserving_Key --
-      -----------------------------------
+      --------------------
+      -- Update_Element --
+      --------------------
 
-      procedure Update_Element_Preserving_Key
+      procedure Update_Element
         (Container : in out Set;
          Position  : Cursor;
          Process   : not null access procedure (Element : in out Element_Type))
       is
          Tree : Tree_Type renames Container.Tree;
+         Node : constant Node_Access := Position.Node;
 
       begin
-         if Position.Node = null then
-            raise Constraint_Error;
+         if Node = null then
+            raise Constraint_Error with "Position cursor equals No_Element";
+         end if;
+
+         if Node.Element = null then
+            raise Program_Error with "Position cursor is bad";
          end if;
 
          if Position.Container /= Container'Unrestricted_Access then
-            raise Program_Error;
+            raise Program_Error with "Position cursor designates wrong set";
          end if;
 
+         pragma Assert (Vet (Tree, Node),
+                        "bad cursor in Update_Element");
+
          declare
-            E : Element_Type renames Position.Node.Element.all;
-            K : Key_Type renames Key (E);
+            E : Element_Type renames Node.Element.all;
+            K : constant Key_Type := Key (E);
 
             B : Natural renames Tree.Busy;
             L : Natural renames Tree.Lock;
@@ -839,24 +987,52 @@ package body Ada.Containers.Indefinite_Ordered_Multisets is
             L := L - 1;
             B := B - 1;
 
-            if K < E
-              or else K > E
-            then
-               null;
-            else
+            if Equivalent_Keys (Left => K, Right => Key (E)) then
                return;
             end if;
          end;
 
-         declare
-            X : Node_Access := Position.Node;
+         --  Delete_Node checks busy-bit
+
+         Tree_Operations.Delete_Node_Sans_Free (Tree, Node);
+
+         Insert_New_Item : declare
+            function New_Node return Node_Access;
+            pragma Inline (New_Node);
+
+            procedure Insert_Post is
+               new Element_Keys.Generic_Insert_Post (New_Node);
+
+            procedure Unconditional_Insert is
+               new Element_Keys.Generic_Unconditional_Insert (Insert_Post);
+
+            --------------
+            -- New_Node --
+            --------------
+
+            function New_Node return Node_Access is
+            begin
+               Node.Color := Red_Black_Trees.Red;
+               Node.Parent := null;
+               Node.Left := null;
+               Node.Right := null;
+
+               return Node;
+            end New_Node;
+
+            Result : Node_Access;
+
+         --  Start of processing for Insert_New_Item
+
          begin
-            Tree_Operations.Delete_Node_Sans_Free (Tree, X);
-            Free (X);
-         end;
+            Unconditional_Insert
+              (Tree => Tree,
+               Key  => Node.Element.all,
+               Node => Result);
 
-         raise Program_Error;
-      end Update_Element_Preserving_Key;
+            pragma Assert (Result = Node);
+         end Insert_New_Item;
+      end Update_Element;
 
    end Generic_Keys;
 
@@ -875,6 +1051,7 @@ package body Ada.Containers.Indefinite_Ordered_Multisets is
 
    procedure Insert (Container : in out Set; New_Item : Element_Type) is
       Position : Cursor;
+      pragma Unreferenced (Position);
    begin
       Insert (Container, New_Item, Position);
    end Insert;
@@ -884,13 +1061,27 @@ package body Ada.Containers.Indefinite_Ordered_Multisets is
       New_Item  : Element_Type;
       Position  : out Cursor)
    is
+   begin
+      Insert_Sans_Hint (Container.Tree, New_Item, Position.Node);
+      Position.Container := Container'Unrestricted_Access;
+   end Insert;
+
+   ----------------------
+   -- Insert_Sans_Hint --
+   ----------------------
+
+   procedure Insert_Sans_Hint
+     (Tree     : in out Tree_Type;
+      New_Item : Element_Type;
+      Node     : out Node_Access)
+   is
       function New_Node return Node_Access;
       pragma Inline (New_Node);
 
       procedure Insert_Post is
         new Element_Keys.Generic_Insert_Post (New_Node);
 
-      procedure Unconditional_Insert_Sans_Hint is
+      procedure Unconditional_Insert is
         new Element_Keys.Generic_Unconditional_Insert (Insert_Post);
 
       --------------
@@ -898,31 +1089,25 @@ package body Ada.Containers.Indefinite_Ordered_Multisets is
       --------------
 
       function New_Node return Node_Access is
-         X : Element_Access := new Element_Type'(New_Item);
+         Element : Element_Access := new Element_Type'(New_Item);
 
       begin
          return new Node_Type'(Parent  => null,
                                Left    => null,
                                Right   => null,
-                               Color   => Red,
-                               Element => X);
-
+                               Color   => Red_Black_Trees.Red,
+                               Element => Element);
       exception
          when others =>
-            Free_Element (X);
+            Free_Element (Element);
             raise;
       end New_Node;
 
-   --  Start of processing for Insert
+   --  Start of processing for Insert_Sans_Hint
 
    begin
-      Unconditional_Insert_Sans_Hint
-        (Container.Tree,
-         New_Item,
-         Position.Node);
-
-      Position.Container := Container'Unrestricted_Access;
-   end Insert;
+      Unconditional_Insert (Tree, New_Item, Node);
+   end Insert_Sans_Hint;
 
    ----------------------
    -- Insert_With_Hint --
@@ -1156,6 +1341,11 @@ package body Ada.Containers.Indefinite_Ordered_Multisets is
 
    function Last_Element (Container : Set) return Element_Type is
    begin
+      if Container.Tree.Last = null then
+         raise Constraint_Error with "set is empty";
+      end if;
+
+      pragma Assert (Container.Tree.Last.Element /= null);
       return Container.Tree.Last.Element.all;
    end Last_Element;
 
@@ -1199,6 +1389,9 @@ package body Ada.Containers.Indefinite_Ordered_Multisets is
          return No_Element;
       end if;
 
+      pragma Assert (Vet (Position.Container.Tree, Position.Node),
+                     "bad cursor in Next");
+
       declare
          Node : constant Node_Access :=
                   Tree_Operations.Next (Position.Node);
@@ -1245,6 +1438,9 @@ package body Ada.Containers.Indefinite_Ordered_Multisets is
          return No_Element;
       end if;
 
+      pragma Assert (Vet (Position.Container.Tree, Position.Node),
+                     "bad cursor in Previous");
+
       declare
          Node : constant Node_Access :=
                   Tree_Operations.Previous (Position.Node);
@@ -1271,29 +1467,40 @@ package body Ada.Containers.Indefinite_Ordered_Multisets is
      (Position : Cursor;
       Process  : not null access procedure (Element : Element_Type))
    is
-      E : Element_Type renames Position.Node.Element.all;
+   begin
+      if Position.Node = null then
+         raise Constraint_Error with "Position cursor equals No_Element";
+      end if;
 
-      S : Set renames Position.Container.all;
-      T : Tree_Type renames S.Tree'Unrestricted_Access.all;
+      if Position.Node.Element = null then
+         raise Program_Error with "Position cursor is bad";
+      end if;
 
-      B : Natural renames T.Busy;
-      L : Natural renames T.Lock;
+      pragma Assert (Vet (Position.Container.Tree, Position.Node),
+                     "bad cursor in Query_Element");
 
-   begin
-      B := B + 1;
-      L := L + 1;
+      declare
+         T : Tree_Type renames Position.Container.Tree;
+
+         B : Natural renames T.Busy;
+         L : Natural renames T.Lock;
 
       begin
-         Process (E);
-      exception
-         when others =>
-            L := L - 1;
-            B := B - 1;
-            raise;
-      end;
+         B := B + 1;
+         L := L + 1;
 
-      L := L - 1;
-      B := B - 1;
+         begin
+            Process (Position.Node.Element.all);
+         exception
+            when others =>
+               L := L - 1;
+               B := B - 1;
+               raise;
+         end;
+
+         L := L - 1;
+         B := B - 1;
+      end;
    end Query_Element;
 
    ----------
@@ -1301,11 +1508,11 @@ package body Ada.Containers.Indefinite_Ordered_Multisets is
    ----------
 
    procedure Read
-     (Stream    : access Root_Stream_Type'Class;
+     (Stream    : not null access Root_Stream_Type'Class;
       Container : out Set)
    is
       function Read_Node
-        (Stream : access Root_Stream_Type'Class) return Node_Access;
+        (Stream : not null access Root_Stream_Type'Class) return Node_Access;
       pragma Inline (Read_Node);
 
       procedure Read is
@@ -1316,7 +1523,7 @@ package body Ada.Containers.Indefinite_Ordered_Multisets is
       ---------------
 
       function Read_Node
-        (Stream : access Root_Stream_Type'Class) return Node_Access
+        (Stream : not null access Root_Stream_Type'Class) return Node_Access
       is
          Node : Node_Access := new Node_Type;
       begin
@@ -1334,6 +1541,14 @@ package body Ada.Containers.Indefinite_Ordered_Multisets is
       Read (Stream, Container.Tree);
    end Read;
 
+   procedure Read
+     (Stream : not null access Root_Stream_Type'Class;
+      Item   : out Cursor)
+   is
+   begin
+      raise Program_Error with "attempt to stream set cursor";
+   end Read;
+
    ---------------------
    -- Replace_Element --
    ---------------------
@@ -1350,7 +1565,8 @@ package body Ada.Containers.Indefinite_Ordered_Multisets is
          null;
       else
          if Tree.Lock > 0 then
-            raise Program_Error;
+            raise Program_Error with
+              "attempt to tamper with cursors (set is locked)";
          end if;
 
          declare
@@ -1382,6 +1598,11 @@ package body Ada.Containers.Indefinite_Ordered_Multisets is
          function New_Node return Node_Access is
          begin
             Node.Element := new Element_Type'(Item);  -- OK if fails
+            Node.Color := Red_Black_Trees.Red;
+            Node.Parent := null;
+            Node.Left := null;
+            Node.Right := null;
+
             return Node;
          end New_Node;
 
@@ -1403,22 +1624,27 @@ package body Ada.Containers.Indefinite_Ordered_Multisets is
    end Replace_Element;
 
    procedure Replace_Element
-    (Container : Set;
+    (Container : in out Set;
      Position  : Cursor;
-     By        : Element_Type)
+     New_Item  : Element_Type)
    is
-      Tree : Tree_Type renames Position.Container.Tree'Unrestricted_Access.all;
-
    begin
       if Position.Node = null then
-         raise Constraint_Error;
+         raise Constraint_Error with "Position cursor equals No_Element";
+      end if;
+
+      if Position.Node.Element = null then
+         raise Program_Error with "Position cursor is bad";
       end if;
 
       if Position.Container /= Container'Unrestricted_Access then
-         raise Program_Error;
+         raise Program_Error with "Position cursor designates wrong set";
       end if;
 
-      Replace_Element (Tree, Position.Node, By);
+      pragma Assert (Vet (Container.Tree, Position.Node),
+                     "bad cursor in Replace_Element");
+
+      Replace_Element (Container.Tree, Position.Node, New_Item);
    end Replace_Element;
 
    ---------------------
@@ -1563,6 +1789,19 @@ package body Ada.Containers.Indefinite_Ordered_Multisets is
       return Set'(Controlled with Tree);
    end Symmetric_Difference;
 
+   ------------
+   -- To_Set --
+   ------------
+
+   function To_Set (New_Item : Element_Type) return Set is
+      Tree : Tree_Type;
+      Node : Node_Access;
+      pragma Unreferenced (Node);
+   begin
+      Insert_Sans_Hint (Tree, New_Item, Node);
+      return Set'(Controlled with Tree);
+   end To_Set;
+
    -----------
    -- Union --
    -----------
@@ -1584,11 +1823,11 @@ package body Ada.Containers.Indefinite_Ordered_Multisets is
    -----------
 
    procedure Write
-     (Stream    : access Root_Stream_Type'Class;
+     (Stream    : not null access Root_Stream_Type'Class;
       Container : Set)
    is
       procedure Write_Node
-        (Stream : access Root_Stream_Type'Class;
+        (Stream : not null access Root_Stream_Type'Class;
          Node   : Node_Access);
       pragma Inline (Write_Node);
 
@@ -1600,7 +1839,7 @@ package body Ada.Containers.Indefinite_Ordered_Multisets is
       ----------------
 
       procedure Write_Node
-        (Stream : access Root_Stream_Type'Class;
+        (Stream : not null access Root_Stream_Type'Class;
          Node   : Node_Access)
       is
       begin
@@ -1613,4 +1852,12 @@ package body Ada.Containers.Indefinite_Ordered_Multisets is
       Write (Stream, Container.Tree);
    end Write;
 
+   procedure Write
+     (Stream : not null access Root_Stream_Type'Class;
+      Item   : Cursor)
+   is
+   begin
+      raise Program_Error with "attempt to stream set cursor";
+   end Write;
+
 end Ada.Containers.Indefinite_Ordered_Multisets;