1 ------------------------------------------------------------------------------
3 -- GNAT LIBRARY COMPONENTS --
5 -- A D A . C O N T A I N E R S . O R D E R E D _ S E T S --
9 -- Copyright (C) 2004-2005 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, 51 Franklin Street, Fifth Floor, --
24 -- Boston, MA 02110-1301, 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 package body Ada.Containers.Ordered_Sets is
49 ------------------------------
50 -- Access to Fields of Node --
51 ------------------------------
53 -- These subprograms provide functional notation for access to fields
54 -- of a node, and procedural notation for modifiying these fields.
56 function Color (Node : Node_Access) return Color_Type;
57 pragma Inline (Color);
59 function Left (Node : Node_Access) return Node_Access;
62 function Parent (Node : Node_Access) return Node_Access;
63 pragma Inline (Parent);
65 function Right (Node : Node_Access) return Node_Access;
66 pragma Inline (Right);
68 procedure Set_Color (Node : Node_Access; Color : Color_Type);
69 pragma Inline (Set_Color);
71 procedure Set_Left (Node : Node_Access; Left : Node_Access);
72 pragma Inline (Set_Left);
74 procedure Set_Right (Node : Node_Access; Right : Node_Access);
75 pragma Inline (Set_Right);
77 procedure Set_Parent (Node : Node_Access; Parent : Node_Access);
78 pragma Inline (Set_Parent);
80 -----------------------
81 -- Local Subprograms --
82 -----------------------
84 function Copy_Node (Source : Node_Access) return Node_Access;
85 pragma Inline (Copy_Node);
87 procedure Insert_With_Hint
88 (Dst_Tree : in out Tree_Type;
89 Dst_Hint : Node_Access;
90 Src_Node : Node_Access;
91 Dst_Node : out Node_Access);
93 function Is_Equal_Node_Node (L, R : Node_Access) return Boolean;
94 pragma Inline (Is_Equal_Node_Node);
96 function Is_Greater_Element_Node
98 Right : Node_Access) return Boolean;
99 pragma Inline (Is_Greater_Element_Node);
101 function Is_Less_Element_Node
102 (Left : Element_Type;
103 Right : Node_Access) return Boolean;
104 pragma Inline (Is_Less_Element_Node);
106 function Is_Less_Node_Node (L, R : Node_Access) return Boolean;
107 pragma Inline (Is_Less_Node_Node);
109 procedure Replace_Element
110 (Tree : in out Tree_Type;
112 Item : Element_Type);
114 --------------------------
115 -- Local Instantiations --
116 --------------------------
119 new Ada.Unchecked_Deallocation (Node_Type, Node_Access);
121 package Tree_Operations is
122 new Red_Black_Trees.Generic_Operations (Tree_Types);
124 procedure Delete_Tree is
125 new Tree_Operations.Generic_Delete_Tree (Free);
127 function Copy_Tree is
128 new Tree_Operations.Generic_Copy_Tree (Copy_Node, Delete_Tree);
133 new Tree_Operations.Generic_Equal (Is_Equal_Node_Node);
135 package Element_Keys is
136 new Red_Black_Trees.Generic_Keys
137 (Tree_Operations => Tree_Operations,
138 Key_Type => Element_Type,
139 Is_Less_Key_Node => Is_Less_Element_Node,
140 Is_Greater_Key_Node => Is_Greater_Element_Node);
143 new Generic_Set_Operations
144 (Tree_Operations => Tree_Operations,
145 Insert_With_Hint => Insert_With_Hint,
146 Copy_Tree => Copy_Tree,
147 Delete_Tree => Delete_Tree,
148 Is_Less => Is_Less_Node_Node,
155 function "<" (Left, Right : Cursor) return Boolean is
157 return Left.Node.Element < Right.Node.Element;
160 function "<" (Left : Cursor; Right : Element_Type) return Boolean is
162 return Left.Node.Element < Right;
165 function "<" (Left : Element_Type; Right : Cursor) return Boolean is
167 return Left < Right.Node.Element;
174 function "=" (Left, Right : Set) return Boolean is
176 return Is_Equal (Left.Tree, Right.Tree);
183 function ">" (Left, Right : Cursor) return Boolean is
185 -- L > R same as R < L
187 return Right.Node.Element < Left.Node.Element;
190 function ">" (Left : Element_Type; Right : Cursor) return Boolean is
192 return Right.Node.Element < Left;
195 function ">" (Left : Cursor; Right : Element_Type) return Boolean is
197 return Right < Left.Node.Element;
205 new Tree_Operations.Generic_Adjust (Copy_Tree);
207 procedure Adjust (Container : in out Set) is
209 Adjust (Container.Tree);
216 function Ceiling (Container : Set; Item : Element_Type) return Cursor is
217 Node : constant Node_Access :=
218 Element_Keys.Ceiling (Container.Tree, Item);
225 return Cursor'(Container'Unrestricted_Access, Node);
233 new Tree_Operations.Generic_Clear (Delete_Tree);
235 procedure Clear (Container : in out Set) is
237 Clear (Container.Tree);
244 function Color (Node : Node_Access) return Color_Type is
255 Item : Element_Type) return Boolean
258 return Find (Container, Item) /= No_Element;
265 function Copy_Node (Source : Node_Access) return Node_Access is
266 Target : constant Node_Access :=
267 new Node_Type'(Parent => null,
270 Color => Source.Color,
271 Element => Source.Element);
280 procedure Delete (Container : in out Set; Position : in out Cursor) is
282 if Position.Node = null then
283 raise Constraint_Error;
286 if Position.Container /= Container'Unrestricted_Access then
290 Tree_Operations.Delete_Node_Sans_Free (Container.Tree, Position.Node);
291 Free (Position.Node);
292 Position.Container := null;
295 procedure Delete (Container : in out Set; Item : Element_Type) is
296 X : Node_Access := Element_Keys.Find (Container.Tree, Item);
300 raise Constraint_Error;
303 Tree_Operations.Delete_Node_Sans_Free (Container.Tree, X);
311 procedure Delete_First (Container : in out Set) is
312 Tree : Tree_Type renames Container.Tree;
313 X : Node_Access := Tree.First;
317 Tree_Operations.Delete_Node_Sans_Free (Tree, X);
326 procedure Delete_Last (Container : in out Set) is
327 Tree : Tree_Type renames Container.Tree;
328 X : Node_Access := Tree.Last;
332 Tree_Operations.Delete_Node_Sans_Free (Tree, X);
341 procedure Difference (Target : in out Set; Source : Set) is
343 Set_Ops.Difference (Target.Tree, Source.Tree);
346 function Difference (Left, Right : Set) return Set is
347 Tree : constant Tree_Type :=
348 Set_Ops.Difference (Left.Tree, Right.Tree);
350 return Set'(Controlled with Tree);
357 function Element (Position : Cursor) return Element_Type is
359 return Position.Node.Element;
362 ---------------------
363 -- Equivalent_Sets --
364 ---------------------
366 function Equivalent_Sets (Left, Right : Set) return Boolean is
367 function Is_Equivalent_Node_Node (L, R : Node_Access) return Boolean;
368 pragma Inline (Is_Equivalent_Node_Node);
370 function Is_Equivalent is
371 new Tree_Operations.Generic_Equal (Is_Equivalent_Node_Node);
373 -----------------------------
374 -- Is_Equivalent_Node_Node --
375 -----------------------------
377 function Is_Equivalent_Node_Node (L, R : Node_Access) return Boolean is
379 if L.Element < R.Element then
381 elsif R.Element < L.Element then
386 end Is_Equivalent_Node_Node;
388 -- Start of processing for Equivalent_Sets
391 return Is_Equivalent (Left.Tree, Right.Tree);
398 procedure Exclude (Container : in out Set; Item : Element_Type) is
399 X : Node_Access := Element_Keys.Find (Container.Tree, Item);
403 Tree_Operations.Delete_Node_Sans_Free (Container.Tree, X);
412 function Find (Container : Set; Item : Element_Type) return Cursor is
413 Node : constant Node_Access :=
414 Element_Keys.Find (Container.Tree, Item);
421 return Cursor'(Container'Unrestricted_Access, Node);
428 function First (Container : Set) return Cursor is
430 if Container.Tree.First = null then
434 return Cursor'(Container'Unrestricted_Access, Container.Tree.First);
441 function First_Element (Container : Set) return Element_Type is
443 return Container.Tree.First.Element;
450 function Floor (Container : Set; Item : Element_Type) return Cursor is
451 Node : constant Node_Access :=
452 Element_Keys.Floor (Container.Tree, Item);
459 return Cursor'(Container'Unrestricted_Access, Node);
466 package body Generic_Keys is
468 -----------------------
469 -- Local Subprograms --
470 -----------------------
472 function Is_Greater_Key_Node
474 Right : Node_Access) return Boolean;
475 pragma Inline (Is_Greater_Key_Node);
477 function Is_Less_Key_Node
479 Right : Node_Access) return Boolean;
480 pragma Inline (Is_Less_Key_Node);
482 --------------------------
483 -- Local Instantiations --
484 --------------------------
487 new Red_Black_Trees.Generic_Keys
488 (Tree_Operations => Tree_Operations,
489 Key_Type => Key_Type,
490 Is_Less_Key_Node => Is_Less_Key_Node,
491 Is_Greater_Key_Node => Is_Greater_Key_Node);
497 function "<" (Left : Key_Type; Right : Cursor) return Boolean is
499 return Left < Right.Node.Element;
502 function "<" (Left : Cursor; Right : Key_Type) return Boolean is
504 return Right > Left.Node.Element;
511 function ">" (Left : Key_Type; Right : Cursor) return Boolean is
513 return Left > Right.Node.Element;
516 function ">" (Left : Cursor; Right : Key_Type) return Boolean is
518 return Right < Left.Node.Element;
525 function Ceiling (Container : Set; Key : Key_Type) return Cursor is
526 Node : constant Node_Access :=
527 Key_Keys.Ceiling (Container.Tree, Key);
534 return Cursor'(Container'Unrestricted_Access, Node);
541 function Contains (Container : Set; Key : Key_Type) return Boolean is
543 return Find (Container, Key) /= No_Element;
550 procedure Delete (Container : in out Set; Key : Key_Type) is
551 X : Node_Access := Key_Keys.Find (Container.Tree, Key);
555 raise Constraint_Error;
558 Delete_Node_Sans_Free (Container.Tree, X);
568 Key : Key_Type) return Element_Type
570 Node : constant Node_Access := Key_Keys.Find (Container.Tree, Key);
580 procedure Exclude (Container : in out Set; Key : Key_Type) is
581 X : Node_Access := Key_Keys.Find (Container.Tree, Key);
585 Delete_Node_Sans_Free (Container.Tree, X);
594 function Find (Container : Set; Key : Key_Type) return Cursor is
595 Node : constant Node_Access := Key_Keys.Find (Container.Tree, Key);
602 return Cursor'(Container'Unrestricted_Access, Node);
609 function Floor (Container : Set; Key : Key_Type) return Cursor is
610 Node : constant Node_Access := Key_Keys.Floor (Container.Tree, Key);
617 return Cursor'(Container'Unrestricted_Access, Node);
620 -------------------------
621 -- Is_Greater_Key_Node --
622 -------------------------
624 function Is_Greater_Key_Node
626 Right : Node_Access) return Boolean
629 return Left > Right.Element;
630 end Is_Greater_Key_Node;
632 ----------------------
633 -- Is_Less_Key_Node --
634 ----------------------
636 function Is_Less_Key_Node
638 Right : Node_Access) return Boolean
641 return Left < Right.Element;
642 end Is_Less_Key_Node;
648 function Key (Position : Cursor) return Key_Type is
650 return Key (Position.Node.Element);
658 (Container : in out Set;
660 New_Item : Element_Type)
662 Node : constant Node_Access := Key_Keys.Find (Container.Tree, Key);
666 raise Constraint_Error;
669 Replace_Element (Container.Tree, Node, New_Item);
672 -----------------------------------
673 -- Update_Element_Preserving_Key --
674 -----------------------------------
676 procedure Update_Element_Preserving_Key
677 (Container : in out Set;
679 Process : not null access procedure (Element : in out Element_Type))
681 Tree : Tree_Type renames Container.Tree;
684 if Position.Node = null then
685 raise Constraint_Error;
688 if Position.Container /= Container'Unrestricted_Access then
693 E : Element_Type renames Position.Node.Element;
694 K : Key_Type renames Key (E);
696 B : Natural renames Tree.Busy;
697 L : Natural renames Tree.Lock;
725 X : Node_Access := Position.Node;
727 Tree_Operations.Delete_Node_Sans_Free (Tree, X);
732 end Update_Element_Preserving_Key;
740 function Has_Element (Position : Cursor) return Boolean is
742 return Position /= No_Element;
749 procedure Include (Container : in out Set; New_Item : Element_Type) is
754 Insert (Container, New_Item, Position, Inserted);
757 if Container.Tree.Lock > 0 then
761 Position.Node.Element := New_Item;
770 (Container : in out Set;
771 New_Item : Element_Type;
772 Position : out Cursor;
773 Inserted : out Boolean)
775 function New_Node return Node_Access;
776 pragma Inline (New_Node);
778 procedure Insert_Post is
779 new Element_Keys.Generic_Insert_Post (New_Node);
781 procedure Insert_Sans_Hint is
782 new Element_Keys.Generic_Conditional_Insert (Insert_Post);
788 function New_Node return Node_Access is
789 Node : constant Node_Access :=
790 new Node_Type'(Parent => null,
794 Element => New_Item);
799 -- Start of processing for Insert
808 Position.Container := Container'Unrestricted_Access;
812 (Container : in out Set;
813 New_Item : Element_Type)
819 Insert (Container, New_Item, Position, Inserted);
822 raise Constraint_Error;
826 ----------------------
827 -- Insert_With_Hint --
828 ----------------------
830 procedure Insert_With_Hint
831 (Dst_Tree : in out Tree_Type;
832 Dst_Hint : Node_Access;
833 Src_Node : Node_Access;
834 Dst_Node : out Node_Access)
838 function New_Node return Node_Access;
839 pragma Inline (New_Node);
841 procedure Insert_Post is
842 new Element_Keys.Generic_Insert_Post (New_Node);
844 procedure Insert_Sans_Hint is
845 new Element_Keys.Generic_Conditional_Insert (Insert_Post);
847 procedure Local_Insert_With_Hint is
848 new Element_Keys.Generic_Conditional_Insert_With_Hint
856 function New_Node return Node_Access is
857 Node : constant Node_Access :=
858 new Node_Type'(Parent => null,
862 Element => Src_Node.Element);
867 -- Start of processing for Insert_With_Hint
870 Local_Insert_With_Hint
876 end Insert_With_Hint;
882 procedure Intersection (Target : in out Set; Source : Set) is
884 Set_Ops.Intersection (Target.Tree, Source.Tree);
887 function Intersection (Left, Right : Set) return Set is
888 Tree : constant Tree_Type :=
889 Set_Ops.Intersection (Left.Tree, Right.Tree);
891 return Set'(Controlled with Tree);
898 function Is_Empty (Container : Set) return Boolean is
900 return Container.Tree.Length = 0;
903 ------------------------
904 -- Is_Equal_Node_Node --
905 ------------------------
907 function Is_Equal_Node_Node (L, R : Node_Access) return Boolean is
909 return L.Element = R.Element;
910 end Is_Equal_Node_Node;
912 -----------------------------
913 -- Is_Greater_Element_Node --
914 -----------------------------
916 function Is_Greater_Element_Node
917 (Left : Element_Type;
918 Right : Node_Access) return Boolean
921 -- Compute e > node same as node < e
923 return Right.Element < Left;
924 end Is_Greater_Element_Node;
926 --------------------------
927 -- Is_Less_Element_Node --
928 --------------------------
930 function Is_Less_Element_Node
931 (Left : Element_Type;
932 Right : Node_Access) return Boolean
935 return Left < Right.Element;
936 end Is_Less_Element_Node;
938 -----------------------
939 -- Is_Less_Node_Node --
940 -----------------------
942 function Is_Less_Node_Node (L, R : Node_Access) return Boolean is
944 return L.Element < R.Element;
945 end Is_Less_Node_Node;
951 function Is_Subset (Subset : Set; Of_Set : Set) return Boolean is
953 return Set_Ops.Is_Subset (Subset => Subset.Tree, Of_Set => Of_Set.Tree);
962 Process : not null access procedure (Position : Cursor))
964 procedure Process_Node (Node : Node_Access);
965 pragma Inline (Process_Node);
967 procedure Local_Iterate is
968 new Tree_Operations.Generic_Iteration (Process_Node);
974 procedure Process_Node (Node : Node_Access) is
976 Process (Cursor'(Container'Unrestricted_Access, Node));
979 T : Tree_Type renames Container.Tree'Unrestricted_Access.all;
980 B : Natural renames T.Busy;
982 -- Start of prccessing for Iterate
1002 function Last (Container : Set) return Cursor is
1004 if Container.Tree.Last = null then
1008 return Cursor'(Container'Unrestricted_Access, Container.Tree.Last);
1015 function Last_Element (Container : Set) return Element_Type is
1017 return Container.Tree.Last.Element;
1024 function Left (Node : Node_Access) return Node_Access is
1033 function Length (Container : Set) return Count_Type is
1035 return Container.Tree.Length;
1043 new Tree_Operations.Generic_Move (Clear);
1045 procedure Move (Target : in out Set; Source : in out Set) is
1047 Move (Target => Target.Tree, Source => Source.Tree);
1054 function Next (Position : Cursor) return Cursor is
1056 if Position = No_Element then
1061 Node : constant Node_Access :=
1062 Tree_Operations.Next (Position.Node);
1069 return Cursor'(Position.Container, Node);
1073 procedure Next (Position : in out Cursor) is
1075 Position := Next (Position);
1082 function Overlap (Left, Right : Set) return Boolean is
1084 return Set_Ops.Overlap (Left.Tree, Right.Tree);
1091 function Parent (Node : Node_Access) return Node_Access is
1100 function Previous (Position : Cursor) return Cursor is
1102 if Position = No_Element then
1107 Node : constant Node_Access :=
1108 Tree_Operations.Previous (Position.Node);
1115 return Cursor'(Position.Container, Node);
1119 procedure Previous (Position : in out Cursor) is
1121 Position := Previous (Position);
1128 procedure Query_Element
1130 Process : not null access procedure (Element : Element_Type))
1132 E : Element_Type renames Position.Node.Element;
1134 S : Set renames Position.Container.all;
1135 T : Tree_Type renames S.Tree'Unrestricted_Access.all;
1137 B : Natural renames T.Busy;
1138 L : Natural renames T.Lock;
1162 (Stream : access Root_Stream_Type'Class;
1163 Container : out Set)
1166 (Stream : access Root_Stream_Type'Class) return Node_Access;
1167 pragma Inline (Read_Node);
1170 new Tree_Operations.Generic_Read (Clear, Read_Node);
1177 (Stream : access Root_Stream_Type'Class) return Node_Access
1179 Node : Node_Access := new Node_Type;
1182 Element_Type'Read (Stream, Node.Element);
1191 -- Start of processing for Read
1194 Read (Stream, Container.Tree);
1201 procedure Replace (Container : in out Set; New_Item : Element_Type) is
1202 Node : constant Node_Access :=
1203 Element_Keys.Find (Container.Tree, New_Item);
1207 raise Constraint_Error;
1210 if Container.Tree.Lock > 0 then
1211 raise Program_Error;
1214 Node.Element := New_Item;
1217 ---------------------
1218 -- Replace_Element --
1219 ---------------------
1221 procedure Replace_Element
1222 (Tree : in out Tree_Type;
1224 Item : Element_Type)
1227 if Item < Node.Element
1228 or else Node.Element < Item
1232 if Tree.Lock > 0 then
1233 raise Program_Error;
1236 Node.Element := Item;
1240 Tree_Operations.Delete_Node_Sans_Free (Tree, Node); -- Checks busy-bit
1242 Insert_New_Item : declare
1243 function New_Node return Node_Access;
1244 pragma Inline (New_Node);
1246 procedure Insert_Post is
1247 new Element_Keys.Generic_Insert_Post (New_Node);
1250 new Element_Keys.Generic_Conditional_Insert (Insert_Post);
1256 function New_Node return Node_Access is
1258 Node.Element := Item;
1262 Result : Node_Access;
1265 -- Start of processing for Insert_New_Item
1272 Success => Inserted); -- TODO: change param name
1275 pragma Assert (Result = Node);
1280 null; -- Assignment must have failed
1281 end Insert_New_Item;
1283 Reinsert_Old_Element : declare
1284 function New_Node return Node_Access;
1285 pragma Inline (New_Node);
1287 procedure Insert_Post is
1288 new Element_Keys.Generic_Insert_Post (New_Node);
1291 new Element_Keys.Generic_Conditional_Insert (Insert_Post);
1297 function New_Node return Node_Access is
1302 Result : Node_Access;
1305 -- Start of processing for Reinsert_Old_Element
1310 Key => Node.Element,
1312 Success => Inserted); -- TODO: change param name
1315 null; -- Assignment must have failed
1316 end Reinsert_Old_Element;
1318 raise Program_Error;
1319 end Replace_Element;
1321 procedure Replace_Element
1326 Tree : Tree_Type renames Container.Tree'Unrestricted_Access.all;
1329 if Position.Node = null then
1330 raise Constraint_Error;
1333 if Position.Container /= Container'Unrestricted_Access then
1334 raise Program_Error;
1337 Replace_Element (Tree, Position.Node, By);
1338 end Replace_Element;
1340 ---------------------
1341 -- Reverse_Iterate --
1342 ---------------------
1344 procedure Reverse_Iterate
1346 Process : not null access procedure (Position : Cursor))
1348 procedure Process_Node (Node : Node_Access);
1349 pragma Inline (Process_Node);
1351 procedure Local_Reverse_Iterate is
1352 new Tree_Operations.Generic_Reverse_Iteration (Process_Node);
1358 procedure Process_Node (Node : Node_Access) is
1360 Process (Cursor'(Container'Unrestricted_Access, Node));
1363 T : Tree_Type renames Container.Tree'Unrestricted_Access.all;
1364 B : Natural renames T.Busy;
1366 -- Start of processing for Reverse_Iterate
1372 Local_Reverse_Iterate (T);
1380 end Reverse_Iterate;
1386 function Right (Node : Node_Access) return Node_Access is
1395 procedure Set_Color (Node : Node_Access; Color : Color_Type) is
1397 Node.Color := Color;
1404 procedure Set_Left (Node : Node_Access; Left : Node_Access) is
1413 procedure Set_Parent (Node : Node_Access; Parent : Node_Access) is
1415 Node.Parent := Parent;
1422 procedure Set_Right (Node : Node_Access; Right : Node_Access) is
1424 Node.Right := Right;
1427 --------------------------
1428 -- Symmetric_Difference --
1429 --------------------------
1431 procedure Symmetric_Difference (Target : in out Set; Source : Set) is
1433 Set_Ops.Symmetric_Difference (Target.Tree, Source.Tree);
1434 end Symmetric_Difference;
1436 function Symmetric_Difference (Left, Right : Set) return Set is
1437 Tree : constant Tree_Type :=
1438 Set_Ops.Symmetric_Difference (Left.Tree, Right.Tree);
1440 return Set'(Controlled with Tree);
1441 end Symmetric_Difference;
1447 procedure Union (Target : in out Set; Source : Set) is
1449 Set_Ops.Union (Target.Tree, Source.Tree);
1452 function Union (Left, Right : Set) return Set is
1453 Tree : constant Tree_Type :=
1454 Set_Ops.Union (Left.Tree, Right.Tree);
1456 return Set'(Controlled with Tree);
1464 (Stream : access Root_Stream_Type'Class;
1467 procedure Write_Node
1468 (Stream : access Root_Stream_Type'Class;
1469 Node : Node_Access);
1470 pragma Inline (Write_Node);
1473 new Tree_Operations.Generic_Write (Write_Node);
1479 procedure Write_Node
1480 (Stream : access Root_Stream_Type'Class;
1484 Element_Type'Write (Stream, Node.Element);
1487 -- Start of processing for Write
1490 Write (Stream, Container.Tree);
1493 end Ada.Containers.Ordered_Sets;