1 ------------------------------------------------------------------------------
3 -- GNAT LIBRARY COMPONENTS --
5 -- A D A . C O N T A I N E R S . --
6 -- I N D E F I N I T E _ O R D E R E D _ S E T S --
10 -- Copyright (C) 2004-2005 Free Software Foundation, Inc. --
12 -- This specification is derived from the Ada Reference Manual for use with --
13 -- GNAT. The copyright notice above, and the license provisions that follow --
14 -- apply solely to the contents of the part following the private keyword. --
16 -- GNAT is free software; you can redistribute it and/or modify it under --
17 -- terms of the GNU General Public License as published by the Free Soft- --
18 -- ware Foundation; either version 2, or (at your option) any later ver- --
19 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
20 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
21 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
22 -- for more details. You should have received a copy of the GNU General --
23 -- Public License distributed with GNAT; see file COPYING. If not, write --
24 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
25 -- Boston, MA 02110-1301, USA. --
27 -- As a special exception, if other files instantiate generics from this --
28 -- unit, or you link this unit with other files to produce an executable, --
29 -- this unit does not by itself cause the resulting executable to be --
30 -- covered by the GNU General Public License. This exception does not --
31 -- however invalidate any other reasons why the executable file might be --
32 -- covered by the GNU Public License. --
34 -- This unit was originally developed by Matthew J Heaney. --
35 ------------------------------------------------------------------------------
37 with Ada.Containers.Red_Black_Trees.Generic_Operations;
38 pragma Elaborate_All (Ada.Containers.Red_Black_Trees.Generic_Operations);
40 with Ada.Containers.Red_Black_Trees.Generic_Keys;
41 pragma Elaborate_All (Ada.Containers.Red_Black_Trees.Generic_Keys);
43 with Ada.Containers.Red_Black_Trees.Generic_Set_Operations;
44 pragma Elaborate_All (Ada.Containers.Red_Black_Trees.Generic_Set_Operations);
46 with Ada.Unchecked_Deallocation;
48 package body Ada.Containers.Indefinite_Ordered_Sets is
50 -----------------------
51 -- Local Subprograms --
52 -----------------------
54 function Color (Node : Node_Access) return Color_Type;
55 pragma Inline (Color);
57 function Copy_Node (Source : Node_Access) return Node_Access;
58 pragma Inline (Copy_Node);
60 procedure Free (X : in out Node_Access);
62 procedure Insert_With_Hint
63 (Dst_Tree : in out Tree_Type;
64 Dst_Hint : Node_Access;
65 Src_Node : Node_Access;
66 Dst_Node : out Node_Access);
68 function Is_Greater_Element_Node
70 Right : Node_Access) return Boolean;
71 pragma Inline (Is_Greater_Element_Node);
73 function Is_Less_Element_Node
75 Right : Node_Access) return Boolean;
76 pragma Inline (Is_Less_Element_Node);
78 function Is_Less_Node_Node (L, R : Node_Access) return Boolean;
79 pragma Inline (Is_Less_Node_Node);
81 function Left (Node : Node_Access) return Node_Access;
84 function Parent (Node : Node_Access) return Node_Access;
85 pragma Inline (Parent);
87 procedure Replace_Element
88 (Tree : in out Tree_Type;
92 function Right (Node : Node_Access) return Node_Access;
93 pragma Inline (Right);
95 procedure Set_Color (Node : Node_Access; Color : Color_Type);
96 pragma Inline (Set_Color);
98 procedure Set_Left (Node : Node_Access; Left : Node_Access);
99 pragma Inline (Set_Left);
101 procedure Set_Parent (Node : Node_Access; Parent : Node_Access);
102 pragma Inline (Set_Parent);
104 procedure Set_Right (Node : Node_Access; Right : Node_Access);
105 pragma Inline (Set_Right);
107 --------------------------
108 -- Local Instantiations --
109 --------------------------
111 procedure Free_Element is
112 new Ada.Unchecked_Deallocation (Element_Type, Element_Access);
114 package Tree_Operations is
115 new Red_Black_Trees.Generic_Operations (Tree_Types);
117 procedure Delete_Tree is
118 new Tree_Operations.Generic_Delete_Tree (Free);
120 function Copy_Tree is
121 new Tree_Operations.Generic_Copy_Tree (Copy_Node, Delete_Tree);
125 package Element_Keys is
126 new Red_Black_Trees.Generic_Keys
127 (Tree_Operations => Tree_Operations,
128 Key_Type => Element_Type,
129 Is_Less_Key_Node => Is_Less_Element_Node,
130 Is_Greater_Key_Node => Is_Greater_Element_Node);
133 new Generic_Set_Operations
134 (Tree_Operations => Tree_Operations,
135 Insert_With_Hint => Insert_With_Hint,
136 Copy_Tree => Copy_Tree,
137 Delete_Tree => Delete_Tree,
138 Is_Less => Is_Less_Node_Node,
145 function "<" (Left, Right : Cursor) return Boolean is
147 return Left.Node.Element.all < Right.Node.Element.all;
150 function "<" (Left : Cursor; Right : Element_Type) return Boolean is
152 return Left.Node.Element.all < Right;
155 function "<" (Left : Element_Type; Right : Cursor) return Boolean is
157 return Left < Right.Node.Element.all;
164 function "=" (Left, Right : Set) return Boolean is
166 function Is_Equal_Node_Node (L, R : Node_Access) return Boolean;
167 pragma Inline (Is_Equal_Node_Node);
170 new Tree_Operations.Generic_Equal (Is_Equal_Node_Node);
172 ------------------------
173 -- Is_Equal_Node_Node --
174 ------------------------
176 function Is_Equal_Node_Node (L, R : Node_Access) return Boolean is
178 return L.Element.all = R.Element.all;
179 end Is_Equal_Node_Node;
181 -- Start of processing for "="
184 return Is_Equal (Left.Tree, Right.Tree);
191 function ">" (Left, Right : Cursor) return Boolean is
193 -- L > R same as R < L
195 return Right.Node.Element.all < Left.Node.Element.all;
198 function ">" (Left : Cursor; Right : Element_Type) return Boolean is
200 return Right < Left.Node.Element.all;
203 function ">" (Left : Element_Type; Right : Cursor) return Boolean is
205 return Right.Node.Element.all < Left;
213 new Tree_Operations.Generic_Adjust (Copy_Tree);
215 procedure Adjust (Container : in out Set) is
217 Adjust (Container.Tree);
224 function Ceiling (Container : Set; Item : Element_Type) return Cursor is
225 Node : constant Node_Access :=
226 Element_Keys.Ceiling (Container.Tree, Item);
233 return Cursor'(Container'Unrestricted_Access, Node);
241 new Tree_Operations.Generic_Clear (Delete_Tree);
243 procedure Clear (Container : in out Set) is
245 Clear (Container.Tree);
252 function Color (Node : Node_Access) return Color_Type is
261 function Contains (Container : Set; Item : Element_Type) return Boolean is
263 return Find (Container, Item) /= No_Element;
270 function Copy_Node (Source : Node_Access) return Node_Access is
271 Element : Element_Access := new Element_Type'(Source.Element.all);
274 return new Node_Type'(Parent => null,
277 Color => Source.Color,
281 Free_Element (Element);
289 procedure Delete (Container : in out Set; Position : in out Cursor) is
291 if Position.Node = null then
292 raise Constraint_Error;
295 if Position.Container /= Container'Unrestricted_Access then
299 Tree_Operations.Delete_Node_Sans_Free (Container.Tree, Position.Node);
300 Free (Position.Node);
301 Position.Container := null;
304 procedure Delete (Container : in out Set; Item : Element_Type) is
306 Element_Keys.Find (Container.Tree, Item);
310 raise Constraint_Error;
313 Delete_Node_Sans_Free (Container.Tree, X);
321 procedure Delete_First (Container : in out Set) is
322 Tree : Tree_Type renames Container.Tree;
323 X : Node_Access := Tree.First;
327 Tree_Operations.Delete_Node_Sans_Free (Tree, X);
336 procedure Delete_Last (Container : in out Set) is
337 Tree : Tree_Type renames Container.Tree;
338 X : Node_Access := Tree.Last;
342 Tree_Operations.Delete_Node_Sans_Free (Tree, X);
351 procedure Difference (Target : in out Set; Source : Set) is
353 Set_Ops.Difference (Target.Tree, Source.Tree);
356 function Difference (Left, Right : Set) return Set is
357 Tree : constant Tree_Type :=
358 Set_Ops.Difference (Left.Tree, Right.Tree);
360 return Set'(Controlled with Tree);
367 function Element (Position : Cursor) return Element_Type is
369 return Position.Node.Element.all;
372 -------------------------
373 -- Equivalent_Elements --
374 -------------------------
376 function Equivalent_Elements (Left, Right : Element_Type) return Boolean is
385 end Equivalent_Elements;
387 ---------------------
388 -- Equivalent_Sets --
389 ---------------------
391 function Equivalent_Sets (Left, Right : Set) return Boolean is
393 function Is_Equivalent_Node_Node (L, R : Node_Access) return Boolean;
394 pragma Inline (Is_Equivalent_Node_Node);
396 function Is_Equivalent is
397 new Tree_Operations.Generic_Equal (Is_Equivalent_Node_Node);
399 -----------------------------
400 -- Is_Equivalent_Node_Node --
401 -----------------------------
403 function Is_Equivalent_Node_Node (L, R : Node_Access) return Boolean is
405 if L.Element.all < R.Element.all then
407 elsif R.Element.all < L.Element.all then
412 end Is_Equivalent_Node_Node;
414 -- Start of processing for Equivalent_Sets
417 return Is_Equivalent (Left.Tree, Right.Tree);
424 procedure Exclude (Container : in out Set; Item : Element_Type) is
426 Element_Keys.Find (Container.Tree, Item);
430 Tree_Operations.Delete_Node_Sans_Free (Container.Tree, X);
439 function Find (Container : Set; Item : Element_Type) return Cursor is
440 Node : constant Node_Access :=
441 Element_Keys.Find (Container.Tree, Item);
448 return Cursor'(Container'Unrestricted_Access, Node);
455 function First (Container : Set) return Cursor is
457 if Container.Tree.First = null then
461 return Cursor'(Container'Unrestricted_Access, Container.Tree.First);
468 function First_Element (Container : Set) return Element_Type is
470 return Container.Tree.First.Element.all;
477 function Floor (Container : Set; Item : Element_Type) return Cursor is
478 Node : constant Node_Access :=
479 Element_Keys.Floor (Container.Tree, Item);
486 return Cursor'(Container'Unrestricted_Access, Node);
493 procedure Free (X : in out Node_Access) is
495 procedure Deallocate is
496 new Ada.Unchecked_Deallocation (Node_Type, Node_Access);
504 Free_Element (X.Element);
519 package body Generic_Keys is
521 -----------------------
522 -- Local Subprograms --
523 -----------------------
525 function Is_Greater_Key_Node
527 Right : Node_Access) return Boolean;
528 pragma Inline (Is_Greater_Key_Node);
530 function Is_Less_Key_Node
532 Right : Node_Access) return Boolean;
533 pragma Inline (Is_Less_Key_Node);
535 --------------------------
536 -- Local Instantiations --
537 --------------------------
540 new Red_Black_Trees.Generic_Keys
541 (Tree_Operations => Tree_Operations,
542 Key_Type => Key_Type,
543 Is_Less_Key_Node => Is_Less_Key_Node,
544 Is_Greater_Key_Node => Is_Greater_Key_Node);
550 function Ceiling (Container : Set; Key : Key_Type) return Cursor is
551 Node : constant Node_Access :=
552 Key_Keys.Ceiling (Container.Tree, Key);
559 return Cursor'(Container'Unrestricted_Access, Node);
566 function Contains (Container : Set; Key : Key_Type) return Boolean is
568 return Find (Container, Key) /= No_Element;
575 procedure Delete (Container : in out Set; Key : Key_Type) is
576 X : Node_Access := Key_Keys.Find (Container.Tree, Key);
580 raise Constraint_Error;
583 Tree_Operations.Delete_Node_Sans_Free (Container.Tree, X);
591 function Element (Container : Set; Key : Key_Type) return Element_Type is
592 Node : constant Node_Access :=
593 Key_Keys.Find (Container.Tree, Key);
596 return Node.Element.all;
599 ---------------------
600 -- Equivalent_Keys --
601 ---------------------
603 function Equivalent_Keys (Left, Right : Key_Type) return Boolean is
618 procedure Exclude (Container : in out Set; Key : Key_Type) is
619 X : Node_Access := Key_Keys.Find (Container.Tree, Key);
623 Tree_Operations.Delete_Node_Sans_Free (Container.Tree, X);
632 function Find (Container : Set; Key : Key_Type) return Cursor is
633 Node : constant Node_Access :=
634 Key_Keys.Find (Container.Tree, Key);
641 return Cursor'(Container'Unrestricted_Access, Node);
648 function Floor (Container : Set; Key : Key_Type) return Cursor is
649 Node : constant Node_Access :=
650 Key_Keys.Floor (Container.Tree, Key);
657 return Cursor'(Container'Unrestricted_Access, Node);
660 -------------------------
661 -- Is_Greater_Key_Node --
662 -------------------------
664 function Is_Greater_Key_Node
666 Right : Node_Access) return Boolean is
668 return Key (Right.Element.all) < Left;
669 end Is_Greater_Key_Node;
671 ----------------------
672 -- Is_Less_Key_Node --
673 ----------------------
675 function Is_Less_Key_Node
677 Right : Node_Access) return Boolean is
679 return Left < Key (Right.Element.all);
680 end Is_Less_Key_Node;
686 function Key (Position : Cursor) return Key_Type is
688 return Key (Position.Node.Element.all);
696 (Container : in out Set;
698 New_Item : Element_Type)
700 Node : constant Node_Access := Key_Keys.Find (Container.Tree, Key);
704 raise Constraint_Error;
707 Replace_Element (Container.Tree, Node, New_Item);
710 -----------------------------------
711 -- Update_Element_Preserving_Key --
712 -----------------------------------
714 procedure Update_Element_Preserving_Key
715 (Container : in out Set;
717 Process : not null access
718 procedure (Element : in out Element_Type))
720 Tree : Tree_Type renames Container.Tree;
723 if Position.Node = null then
724 raise Constraint_Error;
727 if Position.Container /= Container'Unrestricted_Access then
732 E : Element_Type renames Position.Node.Element.all;
733 K : constant Key_Type := Key (E);
735 B : Natural renames Tree.Busy;
736 L : Natural renames Tree.Lock;
754 if Equivalent_Keys (K, Key (E)) then
760 X : Node_Access := Position.Node;
762 Tree_Operations.Delete_Node_Sans_Free (Tree, X);
767 end Update_Element_Preserving_Key;
775 function Has_Element (Position : Cursor) return Boolean is
777 return Position /= No_Element;
784 procedure Include (Container : in out Set; New_Item : Element_Type) is
791 Insert (Container, New_Item, Position, Inserted);
794 if Container.Tree.Lock > 0 then
798 X := Position.Node.Element;
799 Position.Node.Element := new Element_Type'(New_Item);
809 (Container : in out Set;
810 New_Item : Element_Type;
811 Position : out Cursor;
812 Inserted : out Boolean)
814 function New_Node return Node_Access;
815 pragma Inline (New_Node);
817 procedure Insert_Post is
818 new Element_Keys.Generic_Insert_Post (New_Node);
820 procedure Insert_Sans_Hint is
821 new Element_Keys.Generic_Conditional_Insert (Insert_Post);
827 function New_Node return Node_Access is
828 Element : Element_Access := new Element_Type'(New_Item);
830 return new Node_Type'(Parent => null,
837 Free_Element (Element);
841 -- Start of processing for Insert
850 Position.Container := Container'Unrestricted_Access;
853 procedure Insert (Container : in out Set; New_Item : Element_Type) is
857 Insert (Container, New_Item, Position, Inserted);
860 raise Constraint_Error;
864 ----------------------
865 -- Insert_With_Hint --
866 ----------------------
868 procedure Insert_With_Hint
869 (Dst_Tree : in out Tree_Type;
870 Dst_Hint : Node_Access;
871 Src_Node : Node_Access;
872 Dst_Node : out Node_Access)
876 function New_Node return Node_Access;
878 procedure Insert_Post is
879 new Element_Keys.Generic_Insert_Post (New_Node);
881 procedure Insert_Sans_Hint is
882 new Element_Keys.Generic_Conditional_Insert (Insert_Post);
884 procedure Insert_With_Hint is
885 new Element_Keys.Generic_Conditional_Insert_With_Hint
893 function New_Node return Node_Access is
894 Element : Element_Access :=
895 new Element_Type'(Src_Node.Element.all);
900 Node := new Node_Type;
903 Free_Element (Element);
907 Node.Element := Element;
911 -- Start of processing for Insert_With_Hint
917 Src_Node.Element.all,
920 end Insert_With_Hint;
926 procedure Intersection (Target : in out Set; Source : Set) is
928 Set_Ops.Intersection (Target.Tree, Source.Tree);
931 function Intersection (Left, Right : Set) return Set is
932 Tree : constant Tree_Type :=
933 Set_Ops.Intersection (Left.Tree, Right.Tree);
935 return Set'(Controlled with Tree);
942 function Is_Empty (Container : Set) return Boolean is
944 return Container.Tree.Length = 0;
947 -----------------------------
948 -- Is_Greater_Element_Node --
949 -----------------------------
951 function Is_Greater_Element_Node
952 (Left : Element_Type;
953 Right : Node_Access) return Boolean is
955 -- e > node same as node < e
957 return Right.Element.all < Left;
958 end Is_Greater_Element_Node;
960 --------------------------
961 -- Is_Less_Element_Node --
962 --------------------------
964 function Is_Less_Element_Node
965 (Left : Element_Type;
966 Right : Node_Access) return Boolean is
968 return Left < Right.Element.all;
969 end Is_Less_Element_Node;
971 -----------------------
972 -- Is_Less_Node_Node --
973 -----------------------
975 function Is_Less_Node_Node (L, R : Node_Access) return Boolean is
977 return L.Element.all < R.Element.all;
978 end Is_Less_Node_Node;
984 function Is_Subset (Subset : Set; Of_Set : Set) return Boolean is
986 return Set_Ops.Is_Subset (Subset => Subset.Tree, Of_Set => Of_Set.Tree);
995 Process : not null access procedure (Position : Cursor))
997 procedure Process_Node (Node : Node_Access);
998 pragma Inline (Process_Node);
1000 procedure Local_Iterate is
1001 new Tree_Operations.Generic_Iteration (Process_Node);
1007 procedure Process_Node (Node : Node_Access) is
1009 Process (Cursor'(Container'Unrestricted_Access, Node));
1012 T : Tree_Type renames Container.Tree'Unrestricted_Access.all;
1013 B : Natural renames T.Busy;
1015 -- Start of prccessing for Iterate
1035 function Last (Container : Set) return Cursor is
1037 if Container.Tree.Last = null then
1041 return Cursor'(Container'Unrestricted_Access, Container.Tree.Last);
1048 function Last_Element (Container : Set) return Element_Type is
1050 return Container.Tree.Last.Element.all;
1057 function Left (Node : Node_Access) return Node_Access is
1066 function Length (Container : Set) return Count_Type is
1068 return Container.Tree.Length;
1076 new Tree_Operations.Generic_Move (Clear);
1078 procedure Move (Target : in out Set; Source : in out Set) is
1080 Move (Target => Target.Tree, Source => Source.Tree);
1087 procedure Next (Position : in out Cursor) is
1089 Position := Next (Position);
1092 function Next (Position : Cursor) return Cursor is
1094 if Position = No_Element then
1099 Node : constant Node_Access :=
1100 Tree_Operations.Next (Position.Node);
1107 return Cursor'(Position.Container, Node);
1115 function Overlap (Left, Right : Set) return Boolean is
1117 return Set_Ops.Overlap (Left.Tree, Right.Tree);
1124 function Parent (Node : Node_Access) return Node_Access is
1133 procedure Previous (Position : in out Cursor) is
1135 Position := Previous (Position);
1138 function Previous (Position : Cursor) return Cursor is
1140 if Position = No_Element then
1145 Node : constant Node_Access :=
1146 Tree_Operations.Previous (Position.Node);
1153 return Cursor'(Position.Container, Node);
1161 procedure Query_Element
1163 Process : not null access procedure (Element : Element_Type))
1165 E : Element_Type renames Position.Node.Element.all;
1167 S : Set renames Position.Container.all;
1168 T : Tree_Type renames S.Tree'Unrestricted_Access.all;
1170 B : Natural renames T.Busy;
1171 L : Natural renames T.Lock;
1195 (Stream : access Root_Stream_Type'Class;
1196 Container : out Set)
1199 (Stream : access Root_Stream_Type'Class) return Node_Access;
1200 pragma Inline (Read_Node);
1203 new Tree_Operations.Generic_Read (Clear, Read_Node);
1210 (Stream : access Root_Stream_Type'Class) return Node_Access
1212 Node : Node_Access := new Node_Type;
1215 Node.Element := new Element_Type'(Element_Type'Input (Stream));
1220 Free (Node); -- Note that Free deallocates elem too
1224 -- Start of processing for Read
1227 Read (Stream, Container.Tree);
1234 procedure Replace (Container : in out Set; New_Item : Element_Type) is
1235 Node : constant Node_Access :=
1236 Element_Keys.Find (Container.Tree, New_Item);
1242 raise Constraint_Error;
1246 Node.Element := new Element_Type'(New_Item);
1250 ---------------------
1251 -- Replace_Element --
1252 ---------------------
1254 procedure Replace_Element
1255 (Tree : in out Tree_Type;
1257 Item : Element_Type)
1260 if Item < Node.Element.all
1261 or else Node.Element.all < Item
1265 if Tree.Lock > 0 then
1266 raise Program_Error;
1270 X : Element_Access := Node.Element;
1272 Node.Element := new Element_Type'(Item);
1279 Tree_Operations.Delete_Node_Sans_Free (Tree, Node); -- Checks busy-bit
1281 Insert_New_Item : declare
1282 function New_Node return Node_Access;
1283 pragma Inline (New_Node);
1285 procedure Insert_Post is
1286 new Element_Keys.Generic_Insert_Post (New_Node);
1289 new Element_Keys.Generic_Conditional_Insert (Insert_Post);
1295 function New_Node return Node_Access is
1297 Node.Element := new Element_Type'(Item); -- OK if fails
1301 Result : Node_Access;
1304 X : Element_Access := Node.Element;
1306 -- Start of processing for Insert_New_Item
1309 Attempt_Insert : begin
1314 Success => Inserted); -- TODO: change name of formal param
1321 pragma Assert (Result = Node);
1322 Free_Element (X); -- OK if fails
1325 end Insert_New_Item;
1327 Reinsert_Old_Element : declare
1328 function New_Node return Node_Access;
1329 pragma Inline (New_Node);
1331 procedure Insert_Post is
1332 new Element_Keys.Generic_Insert_Post (New_Node);
1335 new Element_Keys.Generic_Conditional_Insert (Insert_Post);
1341 function New_Node return Node_Access is
1346 Result : Node_Access;
1349 -- Start of processing for Reinsert_Old_Element
1354 Key => Node.Element.all,
1356 Success => Inserted); -- TODO: change name of formal param
1360 end Reinsert_Old_Element;
1362 raise Program_Error;
1363 end Replace_Element;
1365 procedure Replace_Element
1366 (Container : in out Set;
1368 New_Item : Element_Type)
1371 if Position.Node = null then
1372 raise Constraint_Error;
1375 if Position.Container /= Container'Unrestricted_Access then
1376 raise Program_Error;
1379 Replace_Element (Container.Tree, Position.Node, New_Item);
1380 end Replace_Element;
1382 ---------------------
1383 -- Reverse_Iterate --
1384 ---------------------
1386 procedure Reverse_Iterate
1388 Process : not null access procedure (Position : Cursor))
1390 procedure Process_Node (Node : Node_Access);
1391 pragma Inline (Process_Node);
1393 procedure Local_Reverse_Iterate is
1394 new Tree_Operations.Generic_Reverse_Iteration (Process_Node);
1400 procedure Process_Node (Node : Node_Access) is
1402 Process (Cursor'(Container'Unrestricted_Access, Node));
1405 T : Tree_Type renames Container.Tree'Unrestricted_Access.all;
1406 B : Natural renames T.Busy;
1408 -- Start of processing for Reverse_Iterate
1414 Local_Reverse_Iterate (T);
1422 end Reverse_Iterate;
1428 function Right (Node : Node_Access) return Node_Access is
1437 procedure Set_Color (Node : Node_Access; Color : Color_Type) is
1439 Node.Color := Color;
1446 procedure Set_Left (Node : Node_Access; Left : Node_Access) is
1455 procedure Set_Parent (Node : Node_Access; Parent : Node_Access) is
1457 Node.Parent := Parent;
1464 procedure Set_Right (Node : Node_Access; Right : Node_Access) is
1466 Node.Right := Right;
1469 --------------------------
1470 -- Symmetric_Difference --
1471 --------------------------
1473 procedure Symmetric_Difference (Target : in out Set; Source : Set) is
1475 Set_Ops.Symmetric_Difference (Target.Tree, Source.Tree);
1476 end Symmetric_Difference;
1478 function Symmetric_Difference (Left, Right : Set) return Set is
1479 Tree : constant Tree_Type :=
1480 Set_Ops.Symmetric_Difference (Left.Tree, Right.Tree);
1482 return Set'(Controlled with Tree);
1483 end Symmetric_Difference;
1489 procedure Union (Target : in out Set; Source : Set) is
1491 Set_Ops.Union (Target.Tree, Source.Tree);
1494 function Union (Left, Right : Set) return Set is
1495 Tree : constant Tree_Type :=
1496 Set_Ops.Union (Left.Tree, Right.Tree);
1498 return Set'(Controlled with Tree);
1506 (Stream : access Root_Stream_Type'Class;
1509 procedure Write_Node
1510 (Stream : access Root_Stream_Type'Class;
1511 Node : Node_Access);
1512 pragma Inline (Write_Node);
1515 new Tree_Operations.Generic_Write (Write_Node);
1521 procedure Write_Node
1522 (Stream : access Root_Stream_Type'Class;
1526 Element_Type'Output (Stream, Node.Element.all);
1529 -- Start of processing for Write
1532 Write (Stream, Container.Tree);
1535 end Ada.Containers.Indefinite_Ordered_Sets;