1 ------------------------------------------------------------------------------
3 -- GNAT LIBRARY COMPONENTS --
5 -- ADA.CONTAINERS.ORDERED_SETS --
9 -- Copyright (C) 2004 Free Software Foundation, Inc. --
11 -- This specification is derived from the Ada Reference Manual for use with --
12 -- GNAT. The copyright notice above, and the license provisions that follow --
13 -- apply solely to the contents of the part following the private keyword. --
15 -- GNAT is free software; you can redistribute it and/or modify it under --
16 -- terms of the GNU General Public License as published by the Free Soft- --
17 -- ware Foundation; either version 2, or (at your option) any later ver- --
18 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
19 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
20 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
21 -- for more details. You should have received a copy of the GNU General --
22 -- Public License distributed with GNAT; see file COPYING. If not, write --
23 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
24 -- MA 02111-1307, USA. --
26 -- As a special exception, if other files instantiate generics from this --
27 -- unit, or you link this unit with other files to produce an executable, --
28 -- this unit does not by itself cause the resulting executable to be --
29 -- covered by the GNU General Public License. This exception does not --
30 -- however invalidate any other reasons why the executable file might be --
31 -- covered by the GNU Public License. --
33 -- This unit was originally developed by Matthew J Heaney. --
34 ------------------------------------------------------------------------------
36 with Ada.Unchecked_Deallocation;
38 with Ada.Containers.Red_Black_Trees.Generic_Operations;
39 pragma Elaborate_All (Ada.Containers.Red_Black_Trees.Generic_Operations);
41 with Ada.Containers.Red_Black_Trees.Generic_Keys;
42 pragma Elaborate_All (Ada.Containers.Red_Black_Trees.Generic_Keys);
44 with Ada.Containers.Red_Black_Trees.Generic_Set_Operations;
45 pragma Elaborate_All (Ada.Containers.Red_Black_Trees.Generic_Set_Operations);
47 with System; use type System.Address;
49 package body Ada.Containers.Ordered_Sets is
53 type Node_Type is limited record
57 Color : Red_Black_Trees.Color_Type := Red;
58 Element : Element_Type;
61 ------------------------------
62 -- Access to Fields of Node --
63 ------------------------------
65 -- These subprograms provide functional notation for access to fields
66 -- of a node, and procedural notation for modifiying these fields.
68 function Color (Node : Node_Access) return Color_Type;
69 pragma Inline (Color);
71 function Left (Node : Node_Access) return Node_Access;
74 function Parent (Node : Node_Access) return Node_Access;
75 pragma Inline (Parent);
77 function Right (Node : Node_Access) return Node_Access;
78 pragma Inline (Right);
80 procedure Set_Color (Node : Node_Access; Color : Color_Type);
81 pragma Inline (Set_Color);
83 procedure Set_Left (Node : Node_Access; Left : Node_Access);
84 pragma Inline (Set_Left);
86 procedure Set_Right (Node : Node_Access; Right : Node_Access);
87 pragma Inline (Set_Right);
89 procedure Set_Parent (Node : Node_Access; Parent : Node_Access);
90 pragma Inline (Set_Parent);
92 -----------------------
93 -- Local Subprograms --
94 -----------------------
96 function Copy_Node (Source : Node_Access) return Node_Access;
97 pragma Inline (Copy_Node);
99 function Copy_Tree (Source_Root : Node_Access) return Node_Access;
101 procedure Delete_Tree (X : in out Node_Access);
103 procedure Insert_With_Hint
104 (Dst_Tree : in out Tree_Type;
105 Dst_Hint : Node_Access;
106 Src_Node : Node_Access;
107 Dst_Node : out Node_Access);
109 function Is_Equal_Node_Node (L, R : Node_Access) return Boolean;
110 pragma Inline (Is_Equal_Node_Node);
112 function Is_Greater_Element_Node
113 (Left : Element_Type;
114 Right : Node_Access) return Boolean;
115 pragma Inline (Is_Greater_Element_Node);
117 function Is_Less_Element_Node
118 (Left : Element_Type;
119 Right : Node_Access) return Boolean;
120 pragma Inline (Is_Less_Element_Node);
122 function Is_Less_Node_Node (L, R : Node_Access) return Boolean;
123 pragma Inline (Is_Less_Node_Node);
125 --------------------------
126 -- Local Instantiations --
127 --------------------------
129 package Tree_Operations is
130 new Red_Black_Trees.Generic_Operations
131 (Tree_Types => Tree_Types,
132 Null_Node => Node_Access'(null));
137 new Ada.Unchecked_Deallocation (Node_Type, Node_Access);
140 new Tree_Operations.Generic_Equal (Is_Equal_Node_Node);
142 package Element_Keys is
143 new Red_Black_Trees.Generic_Keys
144 (Tree_Operations => Tree_Operations,
145 Key_Type => Element_Type,
146 Is_Less_Key_Node => Is_Less_Element_Node,
147 Is_Greater_Key_Node => Is_Greater_Element_Node);
150 new Generic_Set_Operations
151 (Tree_Operations => Tree_Operations,
152 Insert_With_Hint => Insert_With_Hint,
153 Copy_Tree => Copy_Tree,
154 Delete_Tree => Delete_Tree,
155 Is_Less => Is_Less_Node_Node,
162 function "<" (Left, Right : Cursor) return Boolean is
164 return Left.Node.Element < Right.Node.Element;
167 function "<" (Left : Cursor; Right : Element_Type) return Boolean is
169 return Left.Node.Element < Right;
172 function "<" (Left : Element_Type; Right : Cursor) return Boolean is
174 return Left < Right.Node.Element;
181 function "=" (Left, Right : Set) return Boolean is
183 if Left'Address = Right'Address then
187 return Is_Equal (Left.Tree, Right.Tree);
194 function ">" (Left, Right : Cursor) return Boolean is
196 -- L > R same as R < L
198 return Right.Node.Element < Left.Node.Element;
201 function ">" (Left : Element_Type; Right : Cursor) return Boolean is
203 return Right.Node.Element < Left;
206 function ">" (Left : Cursor; Right : Element_Type) return Boolean is
208 return Right < Left.Node.Element;
215 procedure Adjust (Container : in out Set) is
216 Tree : Tree_Type renames Container.Tree;
218 N : constant Count_Type := Tree.Length;
219 X : constant Node_Access := Tree.Root;
223 pragma Assert (X = null);
227 Tree := (Length => 0, others => null);
229 Tree.Root := Copy_Tree (X);
230 Tree.First := Min (Tree.Root);
231 Tree.Last := Max (Tree.Root);
239 function Ceiling (Container : Set; Item : Element_Type) return Cursor is
240 Node : constant Node_Access :=
241 Element_Keys.Ceiling (Container.Tree, Item);
248 return Cursor'(Container'Unchecked_Access, Node);
255 procedure Clear (Container : in out Set) is
256 Tree : Tree_Type renames Container.Tree;
257 Root : Node_Access := Tree.Root;
259 Tree := (Length => 0, others => null);
267 function Color (Node : Node_Access) return Color_Type is
278 Item : Element_Type) return Boolean
281 return Find (Container, Item) /= No_Element;
288 function Copy_Node (Source : Node_Access) return Node_Access is
289 Target : constant Node_Access :=
290 new Node_Type'(Parent => null,
293 Color => Source.Color,
294 Element => Source.Element);
303 function Copy_Tree (Source_Root : Node_Access) return Node_Access is
304 Target_Root : Node_Access := Copy_Node (Source_Root);
309 if Source_Root.Right /= null then
310 Target_Root.Right := Copy_Tree (Source_Root.Right);
311 Target_Root.Right.Parent := Target_Root;
315 X := Source_Root.Left;
318 Y : Node_Access := Copy_Node (X);
324 if X.Right /= null then
325 Y.Right := Copy_Tree (X.Right);
339 Delete_Tree (Target_Root);
347 procedure Delete (Container : in out Set; Position : in out Cursor) is
349 if Position = No_Element then
353 if Position.Container /= Set_Access'(Container'Unchecked_Access) then
357 Delete_Node_Sans_Free (Container.Tree, Position.Node);
358 Free (Position.Node);
359 Position.Container := null;
362 procedure Delete (Container : in out Set; Item : Element_Type) is
363 X : Node_Access := Element_Keys.Find (Container.Tree, Item);
367 raise Constraint_Error;
370 Delete_Node_Sans_Free (Container.Tree, X);
378 procedure Delete_First (Container : in out Set) is
379 C : Cursor := First (Container);
381 Delete (Container, C);
388 procedure Delete_Last (Container : in out Set) is
389 C : Cursor := Last (Container);
391 Delete (Container, C);
398 procedure Delete_Tree (X : in out Node_Access) is
414 procedure Difference (Target : in out Set; Source : Set) is
416 if Target'Address = Source'Address then
421 Set_Ops.Difference (Target.Tree, Source.Tree);
424 function Difference (Left, Right : Set) return Set is
426 if Left'Address = Right'Address then
431 Tree : constant Tree_Type :=
432 Set_Ops.Difference (Left.Tree, Right.Tree);
434 return (Controlled with Tree);
442 function Element (Position : Cursor) return Element_Type is
444 return Position.Node.Element;
451 procedure Exclude (Container : in out Set; Item : Element_Type) is
452 X : Node_Access := Element_Keys.Find (Container.Tree, Item);
456 Delete_Node_Sans_Free (Container.Tree, X);
465 function Find (Container : Set; Item : Element_Type) return Cursor is
466 Node : constant Node_Access :=
467 Element_Keys.Find (Container.Tree, Item);
474 return Cursor'(Container'Unchecked_Access, Node);
481 function First (Container : Set) return Cursor is
483 if Container.Tree.First = null then
487 return Cursor'(Container'Unchecked_Access, Container.Tree.First);
494 function First_Element (Container : Set) return Element_Type is
496 return Container.Tree.First.Element;
503 function Floor (Container : Set; Item : Element_Type) return Cursor is
504 Node : constant Node_Access :=
505 Element_Keys.Floor (Container.Tree, Item);
512 return Cursor'(Container'Unchecked_Access, Node);
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 "<" (Left : Key_Type; Right : Cursor) return Boolean is
552 return Left < Right.Node.Element;
555 function "<" (Left : Cursor; Right : Key_Type) return Boolean is
557 return Right > Left.Node.Element;
564 function ">" (Left : Key_Type; Right : Cursor) return Boolean is
566 return Left > Right.Node.Element;
569 function ">" (Left : Cursor; Right : Key_Type) return Boolean is
571 return Right < Left.Node.Element;
578 function Ceiling (Container : Set; Key : Key_Type) return Cursor is
579 Node : constant Node_Access :=
580 Key_Keys.Ceiling (Container.Tree, Key);
587 return Cursor'(Container'Unchecked_Access, Node);
590 ----------------------------
591 -- Checked_Update_Element --
592 ----------------------------
594 procedure Checked_Update_Element
595 (Container : in out Set;
597 Process : not null access procedure (Element : in out Element_Type))
600 if Position.Container = null then
601 raise Constraint_Error;
604 if Position.Container /= Set_Access'(Container'Unchecked_Access) then
609 Old_Key : Key_Type renames Key (Position.Node.Element);
612 Process (Position.Node.Element);
614 if Old_Key < Position.Node.Element
615 or else Old_Key > Position.Node.Element
623 Delete_Node_Sans_Free (Container.Tree, Position.Node);
626 Result : Node_Access;
629 function New_Node return Node_Access;
630 pragma Inline (New_Node);
632 procedure Local_Insert_Post is
633 new Key_Keys.Generic_Insert_Post (New_Node);
635 procedure Local_Conditional_Insert is
636 new Key_Keys.Generic_Conditional_Insert (Local_Insert_Post);
642 function New_Node return Node_Access is
644 return Position.Node;
649 Local_Conditional_Insert
650 (Tree => Container.Tree,
651 Key => Key (Position.Node.Element),
657 X : Node_Access := Position.Node;
665 pragma Assert (Result = Position.Node);
667 end Checked_Update_Element;
673 function Contains (Container : Set; Key : Key_Type) return Boolean is
675 return Find (Container, Key) /= No_Element;
682 procedure Delete (Container : in out Set; Key : Key_Type) is
683 X : Node_Access := Key_Keys.Find (Container.Tree, Key);
687 raise Constraint_Error;
690 Delete_Node_Sans_Free (Container.Tree, X);
700 Key : Key_Type) return Element_Type
702 Node : constant Node_Access := Key_Keys.Find (Container.Tree, Key);
711 procedure Exclude (Container : in out Set; Key : Key_Type) is
712 X : Node_Access := Key_Keys.Find (Container.Tree, Key);
715 Delete_Node_Sans_Free (Container.Tree, X);
724 function Find (Container : Set; Key : Key_Type) return Cursor is
725 Node : constant Node_Access := Key_Keys.Find (Container.Tree, Key);
732 return Cursor'(Container'Unchecked_Access, Node);
739 function Floor (Container : Set; Key : Key_Type) return Cursor is
740 Node : constant Node_Access := Key_Keys.Floor (Container.Tree, Key);
747 return Cursor'(Container'Unchecked_Access, Node);
750 -------------------------
751 -- Is_Greater_Key_Node --
752 -------------------------
754 function Is_Greater_Key_Node
756 Right : Node_Access) return Boolean
759 return Left > Right.Element;
760 end Is_Greater_Key_Node;
762 ----------------------
763 -- Is_Less_Key_Node --
764 ----------------------
766 function Is_Less_Key_Node
768 Right : Node_Access) return Boolean
771 return Left < Right.Element;
772 end Is_Less_Key_Node;
778 function Key (Position : Cursor) return Key_Type is
780 return Key (Position.Node.Element);
790 -- (Container : in out Set;
792 -- New_Item : Element_Type)
794 -- Node : Node_Access := Key_Keys.Find (Container.Tree, Key);
797 -- if Node = null then
798 -- raise Constraint_Error;
801 -- Replace_Element (Container, Node, New_Item);
810 function Has_Element (Position : Cursor) return Boolean is
812 return Position /= No_Element;
819 procedure Include (Container : in out Set; New_Item : Element_Type) is
824 Insert (Container, New_Item, Position, Inserted);
827 Position.Node.Element := New_Item;
836 (Container : in out Set;
837 New_Item : Element_Type;
838 Position : out Cursor;
839 Inserted : out Boolean)
841 function New_Node return Node_Access;
842 pragma Inline (New_Node);
844 procedure Insert_Post is
845 new Element_Keys.Generic_Insert_Post (New_Node);
847 procedure Insert_Sans_Hint is
848 new Element_Keys.Generic_Conditional_Insert (Insert_Post);
854 function New_Node return Node_Access is
855 Node : constant Node_Access :=
856 new Node_Type'(Parent => null,
860 Element => New_Item);
865 -- Start of processing for Insert
874 Position.Container := Container'Unchecked_Access;
878 (Container : in out Set;
879 New_Item : Element_Type)
886 Insert (Container, New_Item, Position, Inserted);
889 raise Constraint_Error;
893 ----------------------
894 -- Insert_With_Hint --
895 ----------------------
897 procedure Insert_With_Hint
898 (Dst_Tree : in out Tree_Type;
899 Dst_Hint : Node_Access;
900 Src_Node : Node_Access;
901 Dst_Node : out Node_Access)
905 function New_Node return Node_Access;
906 pragma Inline (New_Node);
908 procedure Insert_Post is
909 new Element_Keys.Generic_Insert_Post (New_Node);
911 procedure Insert_Sans_Hint is
912 new Element_Keys.Generic_Conditional_Insert (Insert_Post);
914 procedure Local_Insert_With_Hint is
915 new Element_Keys.Generic_Conditional_Insert_With_Hint
923 function New_Node return Node_Access is
924 Node : constant Node_Access :=
925 new Node_Type'(Parent => null,
929 Element => Src_Node.Element);
934 -- Start of processing for Insert_With_Hint
937 Local_Insert_With_Hint
943 end Insert_With_Hint;
949 procedure Intersection (Target : in out Set; Source : Set) is
951 if Target'Address = Source'Address then
955 Set_Ops.Intersection (Target.Tree, Source.Tree);
958 function Intersection (Left, Right : Set) return Set is
960 if Left'Address = Right'Address then
965 Tree : constant Tree_Type :=
966 Set_Ops.Intersection (Left.Tree, Right.Tree);
968 return (Controlled with Tree);
976 function Is_Empty (Container : Set) return Boolean is
978 return Length (Container) = 0;
981 ------------------------
982 -- Is_Equal_Node_Node --
983 ------------------------
985 function Is_Equal_Node_Node (L, R : Node_Access) return Boolean is
987 return L.Element = R.Element;
988 end Is_Equal_Node_Node;
990 -----------------------------
991 -- Is_Greater_Element_Node --
992 -----------------------------
994 function Is_Greater_Element_Node
995 (Left : Element_Type;
996 Right : Node_Access) return Boolean
999 -- Compute e > node same as node < e
1001 return Right.Element < Left;
1002 end Is_Greater_Element_Node;
1004 --------------------------
1005 -- Is_Less_Element_Node --
1006 --------------------------
1008 function Is_Less_Element_Node
1009 (Left : Element_Type;
1010 Right : Node_Access) return Boolean
1013 return Left < Right.Element;
1014 end Is_Less_Element_Node;
1016 -----------------------
1017 -- Is_Less_Node_Node --
1018 -----------------------
1020 function Is_Less_Node_Node (L, R : Node_Access) return Boolean is
1022 return L.Element < R.Element;
1023 end Is_Less_Node_Node;
1029 function Is_Subset (Subset : Set; Of_Set : Set) return Boolean is
1031 if Subset'Address = Of_Set'Address then
1035 return Set_Ops.Is_Subset (Subset => Subset.Tree, Of_Set => Of_Set.Tree);
1044 Process : not null access procedure (Position : Cursor))
1046 procedure Process_Node (Node : Node_Access);
1047 pragma Inline (Process_Node);
1049 procedure Local_Iterate is
1050 new Tree_Operations.Generic_Iteration (Process_Node);
1056 procedure Process_Node (Node : Node_Access) is
1058 Process (Cursor'(Container'Unchecked_Access, Node));
1061 -- Start of prccessing for Iterate
1064 Local_Iterate (Container.Tree);
1071 function Last (Container : Set) return Cursor is
1073 if Container.Tree.Last = null then
1077 return Cursor'(Container'Unchecked_Access, Container.Tree.Last);
1084 function Last_Element (Container : Set) return Element_Type is
1086 return Container.Tree.Last.Element;
1093 function Left (Node : Node_Access) return Node_Access is
1102 function Length (Container : Set) return Count_Type is
1104 return Container.Tree.Length;
1111 procedure Move (Target : in out Set; Source : in out Set) is
1113 if Target'Address = Source'Address then
1117 Move (Target => Target.Tree, Source => Source.Tree);
1124 function Next (Position : Cursor) return Cursor is
1126 if Position = No_Element then
1131 Node : constant Node_Access :=
1132 Tree_Operations.Next (Position.Node);
1138 return Cursor'(Position.Container, Node);
1142 procedure Next (Position : in out Cursor) is
1144 Position := Next (Position);
1151 function Overlap (Left, Right : Set) return Boolean is
1153 if Left'Address = Right'Address then
1154 return Left.Tree.Length /= 0;
1157 return Set_Ops.Overlap (Left.Tree, Right.Tree);
1164 function Parent (Node : Node_Access) return Node_Access is
1173 function Previous (Position : Cursor) return Cursor is
1175 if Position = No_Element then
1180 Node : constant Node_Access :=
1181 Tree_Operations.Previous (Position.Node);
1188 return Cursor'(Position.Container, Node);
1192 procedure Previous (Position : in out Cursor) is
1194 Position := Previous (Position);
1201 procedure Query_Element
1203 Process : not null access procedure (Element : Element_Type))
1206 Process (Position.Node.Element);
1214 (Stream : access Root_Stream_Type'Class;
1215 Container : out Set)
1217 N : Count_Type'Base;
1219 function New_Node return Node_Access;
1220 pragma Inline (New_Node);
1222 procedure Local_Read is new Tree_Operations.Generic_Read (New_Node);
1228 function New_Node return Node_Access is
1229 Node : Node_Access := new Node_Type;
1233 Element_Type'Read (Stream, Node.Element);
1244 -- Start of processing for Read
1249 Count_Type'Base'Read (Stream, N);
1250 pragma Assert (N >= 0);
1252 Local_Read (Container.Tree, N);
1259 procedure Replace (Container : in out Set; New_Item : Element_Type) is
1260 Node : constant Node_Access :=
1261 Element_Keys.Find (Container.Tree, New_Item);
1265 raise Constraint_Error;
1268 Node.Element := New_Item;
1271 ---------------------
1272 -- Replace_Element --
1273 ---------------------
1276 -- procedure Replace_Element
1277 -- (Container : in out Set;
1278 -- Position : Node_Access;
1279 -- By : Element_Type)
1281 -- Node : Node_Access := Position;
1284 -- if By < Node.Element
1285 -- or else Node.Element < By
1291 -- Node.Element := By;
1295 -- Delete_Node_Sans_Free (Container.Tree, Node);
1303 -- Delete_Node_Sans_Free (Container.Tree, Node);
1306 -- Node.Element := By;
1314 -- function New_Node return Node_Access;
1315 -- pragma Inline (New_Node);
1317 -- function New_Node return Node_Access is
1322 -- procedure Insert_Post is
1323 -- new Element_Keys.Generic_Insert_Post (New_Node);
1325 -- procedure Insert is
1326 -- new Element_Keys.Generic_Conditional_Insert (Insert_Post);
1328 -- Result : Node_Access;
1329 -- Success : Boolean;
1333 -- (Tree => Container.Tree,
1334 -- Key => Node.Element,
1336 -- Success => Success);
1338 -- if not Success then
1340 -- raise Program_Error;
1343 -- pragma Assert (Result = Node);
1345 -- end Replace_Element;
1348 -- procedure Replace_Element
1349 -- (Container : in out Set;
1350 -- Position : Cursor;
1351 -- By : Element_Type)
1354 -- if Position.Container = null then
1355 -- raise Constraint_Error;
1358 -- if Position.Container /= Set_Access'(Container'Unchecked_Access) then
1359 -- raise Program_Error;
1362 -- Replace_Element (Container, Position.Node, By);
1363 -- end Replace_Element;
1365 ---------------------
1366 -- Reverse_Iterate --
1367 ---------------------
1369 procedure Reverse_Iterate
1371 Process : not null access procedure (Position : Cursor))
1373 procedure Process_Node (Node : Node_Access);
1374 pragma Inline (Process_Node);
1376 procedure Local_Reverse_Iterate is
1377 new Tree_Operations.Generic_Reverse_Iteration (Process_Node);
1383 procedure Process_Node (Node : Node_Access) is
1385 Process (Cursor'(Container'Unchecked_Access, Node));
1388 -- Start of processing for Reverse_Iterate
1391 Local_Reverse_Iterate (Container.Tree);
1392 end Reverse_Iterate;
1398 function Right (Node : Node_Access) return Node_Access is
1407 procedure Set_Color (Node : Node_Access; Color : Color_Type) is
1409 Node.Color := Color;
1416 procedure Set_Left (Node : Node_Access; Left : Node_Access) is
1425 procedure Set_Parent (Node : Node_Access; Parent : Node_Access) is
1427 Node.Parent := Parent;
1434 procedure Set_Right (Node : Node_Access; Right : Node_Access) is
1436 Node.Right := Right;
1439 --------------------------
1440 -- Symmetric_Difference --
1441 --------------------------
1443 procedure Symmetric_Difference (Target : in out Set; Source : Set) is
1445 if Target'Address = Source'Address then
1450 Set_Ops.Symmetric_Difference (Target.Tree, Source.Tree);
1451 end Symmetric_Difference;
1453 function Symmetric_Difference (Left, Right : Set) return Set is
1455 if Left'Address = Right'Address then
1460 Tree : constant Tree_Type :=
1461 Set_Ops.Symmetric_Difference (Left.Tree, Right.Tree);
1463 return (Controlled with Tree);
1465 end Symmetric_Difference;
1471 procedure Union (Target : in out Set; Source : Set) is
1474 if Target'Address = Source'Address then
1478 Set_Ops.Union (Target.Tree, Source.Tree);
1481 function Union (Left, Right : Set) return Set is
1483 if Left'Address = Right'Address then
1488 Tree : constant Tree_Type := Set_Ops.Union (Left.Tree, Right.Tree);
1490 return (Controlled with Tree);
1499 (Stream : access Root_Stream_Type'Class;
1502 procedure Process (Node : Node_Access);
1503 pragma Inline (Process);
1505 procedure Iterate is
1506 new Tree_Operations.Generic_Iteration (Process);
1512 procedure Process (Node : Node_Access) is
1514 Element_Type'Write (Stream, Node.Element);
1517 -- Start of processing for Write
1520 Count_Type'Base'Write (Stream, Container.Tree.Length);
1521 Iterate (Container.Tree);
1527 end Ada.Containers.Ordered_Sets;