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_Sets --
374 ---------------------
376 function Equivalent_Sets (Left, Right : Set) return Boolean is
378 function Is_Equivalent_Node_Node (L, R : Node_Access) return Boolean;
379 pragma Inline (Is_Equivalent_Node_Node);
381 function Is_Equivalent is
382 new Tree_Operations.Generic_Equal (Is_Equivalent_Node_Node);
384 -----------------------------
385 -- Is_Equivalent_Node_Node --
386 -----------------------------
388 function Is_Equivalent_Node_Node (L, R : Node_Access) return Boolean is
390 if L.Element.all < R.Element.all then
392 elsif R.Element.all < L.Element.all then
397 end Is_Equivalent_Node_Node;
399 -- Start of processing for Equivalent_Sets
402 return Is_Equivalent (Left.Tree, Right.Tree);
409 procedure Exclude (Container : in out Set; Item : Element_Type) is
411 Element_Keys.Find (Container.Tree, Item);
415 Tree_Operations.Delete_Node_Sans_Free (Container.Tree, X);
424 function Find (Container : Set; Item : Element_Type) return Cursor is
425 Node : constant Node_Access :=
426 Element_Keys.Find (Container.Tree, Item);
433 return Cursor'(Container'Unrestricted_Access, Node);
440 function First (Container : Set) return Cursor is
442 if Container.Tree.First = null then
446 return Cursor'(Container'Unrestricted_Access, Container.Tree.First);
453 function First_Element (Container : Set) return Element_Type is
455 return Container.Tree.First.Element.all;
462 function Floor (Container : Set; Item : Element_Type) return Cursor is
463 Node : constant Node_Access :=
464 Element_Keys.Floor (Container.Tree, Item);
471 return Cursor'(Container'Unrestricted_Access, Node);
478 procedure Free (X : in out Node_Access) is
480 procedure Deallocate is
481 new Ada.Unchecked_Deallocation (Node_Type, Node_Access);
489 Free_Element (X.Element);
504 package body Generic_Keys is
506 -----------------------
507 -- Local Subprograms --
508 -----------------------
510 function Is_Greater_Key_Node
512 Right : Node_Access) return Boolean;
513 pragma Inline (Is_Greater_Key_Node);
515 function Is_Less_Key_Node
517 Right : Node_Access) return Boolean;
518 pragma Inline (Is_Less_Key_Node);
520 --------------------------
521 -- Local Instantiations --
522 --------------------------
525 new Red_Black_Trees.Generic_Keys
526 (Tree_Operations => Tree_Operations,
527 Key_Type => Key_Type,
528 Is_Less_Key_Node => Is_Less_Key_Node,
529 Is_Greater_Key_Node => Is_Greater_Key_Node);
535 function "<" (Left : Key_Type; Right : Cursor) return Boolean is
537 return Left < Right.Node.Element.all;
540 function "<" (Left : Cursor; Right : Key_Type) return Boolean is
542 return Right > Left.Node.Element.all;
549 function ">" (Left : Key_Type; Right : Cursor) return Boolean is
551 return Left > Right.Node.Element.all;
554 function ">" (Left : Cursor; Right : Key_Type) return Boolean is
556 return Right < Left.Node.Element.all;
563 function Ceiling (Container : Set; Key : Key_Type) return Cursor is
564 Node : constant Node_Access :=
565 Key_Keys.Ceiling (Container.Tree, Key);
572 return Cursor'(Container'Unrestricted_Access, Node);
579 function Contains (Container : Set; Key : Key_Type) return Boolean is
581 return Find (Container, Key) /= No_Element;
588 procedure Delete (Container : in out Set; Key : Key_Type) is
589 X : Node_Access := Key_Keys.Find (Container.Tree, Key);
593 raise Constraint_Error;
596 Tree_Operations.Delete_Node_Sans_Free (Container.Tree, X);
604 function Element (Container : Set; Key : Key_Type) return Element_Type is
605 Node : constant Node_Access :=
606 Key_Keys.Find (Container.Tree, Key);
609 return Node.Element.all;
616 procedure Exclude (Container : in out Set; Key : Key_Type) is
617 X : Node_Access := Key_Keys.Find (Container.Tree, Key);
621 Tree_Operations.Delete_Node_Sans_Free (Container.Tree, X);
630 function Find (Container : Set; Key : Key_Type) return Cursor is
631 Node : constant Node_Access :=
632 Key_Keys.Find (Container.Tree, Key);
639 return Cursor'(Container'Unrestricted_Access, Node);
646 function Floor (Container : Set; Key : Key_Type) return Cursor is
647 Node : constant Node_Access :=
648 Key_Keys.Floor (Container.Tree, Key);
655 return Cursor'(Container'Unrestricted_Access, Node);
658 -------------------------
659 -- Is_Greater_Key_Node --
660 -------------------------
662 function Is_Greater_Key_Node
664 Right : Node_Access) return Boolean is
666 return Left > Right.Element.all;
667 end Is_Greater_Key_Node;
669 ----------------------
670 -- Is_Less_Key_Node --
671 ----------------------
673 function Is_Less_Key_Node
675 Right : Node_Access) return Boolean is
677 return Left < Right.Element.all;
678 end Is_Less_Key_Node;
684 function Key (Position : Cursor) return Key_Type is
686 return Key (Position.Node.Element.all);
694 (Container : in out Set;
696 New_Item : Element_Type)
698 Node : constant Node_Access := Key_Keys.Find (Container.Tree, Key);
702 raise Constraint_Error;
705 Replace_Element (Container.Tree, Node, New_Item);
708 -----------------------------------
709 -- Update_Element_Preserving_Key --
710 -----------------------------------
712 procedure Update_Element_Preserving_Key
713 (Container : in out Set;
715 Process : not null access
716 procedure (Element : in out Element_Type))
718 Tree : Tree_Type renames Container.Tree;
721 if Position.Node = null then
722 raise Constraint_Error;
725 if Position.Container /= Container'Unrestricted_Access then
730 E : Element_Type renames Position.Node.Element.all;
731 K : Key_Type renames Key (E);
733 B : Natural renames Tree.Busy;
734 L : Natural renames Tree.Lock;
762 X : Node_Access := Position.Node;
764 Tree_Operations.Delete_Node_Sans_Free (Tree, X);
769 end Update_Element_Preserving_Key;
777 function Has_Element (Position : Cursor) return Boolean is
779 return Position /= No_Element;
786 procedure Include (Container : in out Set; New_Item : Element_Type) is
793 Insert (Container, New_Item, Position, Inserted);
796 if Container.Tree.Lock > 0 then
800 X := Position.Node.Element;
801 Position.Node.Element := new Element_Type'(New_Item);
811 (Container : in out Set;
812 New_Item : Element_Type;
813 Position : out Cursor;
814 Inserted : out Boolean)
816 function New_Node return Node_Access;
817 pragma Inline (New_Node);
819 procedure Insert_Post is
820 new Element_Keys.Generic_Insert_Post (New_Node);
822 procedure Insert_Sans_Hint is
823 new Element_Keys.Generic_Conditional_Insert (Insert_Post);
829 function New_Node return Node_Access is
830 Element : Element_Access := new Element_Type'(New_Item);
832 return new Node_Type'(Parent => null,
839 Free_Element (Element);
843 -- Start of processing for Insert
852 Position.Container := Container'Unrestricted_Access;
855 procedure Insert (Container : in out Set; New_Item : Element_Type) is
859 Insert (Container, New_Item, Position, Inserted);
862 raise Constraint_Error;
866 ----------------------
867 -- Insert_With_Hint --
868 ----------------------
870 procedure Insert_With_Hint
871 (Dst_Tree : in out Tree_Type;
872 Dst_Hint : Node_Access;
873 Src_Node : Node_Access;
874 Dst_Node : out Node_Access)
878 function New_Node return Node_Access;
880 procedure Insert_Post is
881 new Element_Keys.Generic_Insert_Post (New_Node);
883 procedure Insert_Sans_Hint is
884 new Element_Keys.Generic_Conditional_Insert (Insert_Post);
886 procedure Insert_With_Hint is
887 new Element_Keys.Generic_Conditional_Insert_With_Hint
895 function New_Node return Node_Access is
896 Element : Element_Access :=
897 new Element_Type'(Src_Node.Element.all);
902 Node := new Node_Type;
905 Free_Element (Element);
909 Node.Element := Element;
913 -- Start of processing for Insert_With_Hint
919 Src_Node.Element.all,
922 end Insert_With_Hint;
928 procedure Intersection (Target : in out Set; Source : Set) is
930 Set_Ops.Intersection (Target.Tree, Source.Tree);
933 function Intersection (Left, Right : Set) return Set is
934 Tree : constant Tree_Type :=
935 Set_Ops.Intersection (Left.Tree, Right.Tree);
937 return Set'(Controlled with Tree);
944 function Is_Empty (Container : Set) return Boolean is
946 return Container.Tree.Length = 0;
949 -----------------------------
950 -- Is_Greater_Element_Node --
951 -----------------------------
953 function Is_Greater_Element_Node
954 (Left : Element_Type;
955 Right : Node_Access) return Boolean is
957 -- e > node same as node < e
959 return Right.Element.all < Left;
960 end Is_Greater_Element_Node;
962 --------------------------
963 -- Is_Less_Element_Node --
964 --------------------------
966 function Is_Less_Element_Node
967 (Left : Element_Type;
968 Right : Node_Access) return Boolean is
970 return Left < Right.Element.all;
971 end Is_Less_Element_Node;
973 -----------------------
974 -- Is_Less_Node_Node --
975 -----------------------
977 function Is_Less_Node_Node (L, R : Node_Access) return Boolean is
979 return L.Element.all < R.Element.all;
980 end Is_Less_Node_Node;
986 function Is_Subset (Subset : Set; Of_Set : Set) return Boolean is
988 return Set_Ops.Is_Subset (Subset => Subset.Tree, Of_Set => Of_Set.Tree);
997 Process : not null access procedure (Position : Cursor))
999 procedure Process_Node (Node : Node_Access);
1000 pragma Inline (Process_Node);
1002 procedure Local_Iterate is
1003 new Tree_Operations.Generic_Iteration (Process_Node);
1009 procedure Process_Node (Node : Node_Access) is
1011 Process (Cursor'(Container'Unrestricted_Access, Node));
1014 T : Tree_Type renames Container.Tree'Unrestricted_Access.all;
1015 B : Natural renames T.Busy;
1017 -- Start of prccessing for Iterate
1037 function Last (Container : Set) return Cursor is
1039 if Container.Tree.Last = null then
1043 return Cursor'(Container'Unrestricted_Access, Container.Tree.Last);
1050 function Last_Element (Container : Set) return Element_Type is
1052 return Container.Tree.Last.Element.all;
1059 function Left (Node : Node_Access) return Node_Access is
1068 function Length (Container : Set) return Count_Type is
1070 return Container.Tree.Length;
1078 new Tree_Operations.Generic_Move (Clear);
1080 procedure Move (Target : in out Set; Source : in out Set) is
1082 Move (Target => Target.Tree, Source => Source.Tree);
1089 procedure Next (Position : in out Cursor) is
1091 Position := Next (Position);
1094 function Next (Position : Cursor) return Cursor is
1096 if Position = No_Element then
1101 Node : constant Node_Access :=
1102 Tree_Operations.Next (Position.Node);
1109 return Cursor'(Position.Container, Node);
1117 function Overlap (Left, Right : Set) return Boolean is
1119 return Set_Ops.Overlap (Left.Tree, Right.Tree);
1126 function Parent (Node : Node_Access) return Node_Access is
1135 procedure Previous (Position : in out Cursor) is
1137 Position := Previous (Position);
1140 function Previous (Position : Cursor) return Cursor is
1142 if Position = No_Element then
1147 Node : constant Node_Access :=
1148 Tree_Operations.Previous (Position.Node);
1155 return Cursor'(Position.Container, Node);
1163 procedure Query_Element
1165 Process : not null access procedure (Element : Element_Type))
1167 E : Element_Type renames Position.Node.Element.all;
1169 S : Set renames Position.Container.all;
1170 T : Tree_Type renames S.Tree'Unrestricted_Access.all;
1172 B : Natural renames T.Busy;
1173 L : Natural renames T.Lock;
1197 (Stream : access Root_Stream_Type'Class;
1198 Container : out Set)
1201 (Stream : access Root_Stream_Type'Class) return Node_Access;
1202 pragma Inline (Read_Node);
1205 new Tree_Operations.Generic_Read (Clear, Read_Node);
1212 (Stream : access Root_Stream_Type'Class) return Node_Access
1214 Node : Node_Access := new Node_Type;
1217 Node.Element := new Element_Type'(Element_Type'Input (Stream));
1222 Free (Node); -- Note that Free deallocates elem too
1226 -- Start of processing for Read
1229 Read (Stream, Container.Tree);
1236 procedure Replace (Container : in out Set; New_Item : Element_Type) is
1237 Node : constant Node_Access :=
1238 Element_Keys.Find (Container.Tree, New_Item);
1244 raise Constraint_Error;
1248 Node.Element := new Element_Type'(New_Item);
1252 ---------------------
1253 -- Replace_Element --
1254 ---------------------
1256 procedure Replace_Element
1257 (Tree : in out Tree_Type;
1259 Item : Element_Type)
1262 if Item < Node.Element.all
1263 or else Node.Element.all < Item
1267 if Tree.Lock > 0 then
1268 raise Program_Error;
1272 X : Element_Access := Node.Element;
1274 Node.Element := new Element_Type'(Item);
1281 Tree_Operations.Delete_Node_Sans_Free (Tree, Node); -- Checks busy-bit
1283 Insert_New_Item : 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
1299 Node.Element := new Element_Type'(Item); -- OK if fails
1303 Result : Node_Access;
1306 X : Element_Access := Node.Element;
1308 -- Start of processing for Insert_New_Item
1311 Attempt_Insert : begin
1316 Success => Inserted); -- TODO: change name of formal param
1323 pragma Assert (Result = Node);
1324 Free_Element (X); -- OK if fails
1327 end Insert_New_Item;
1329 Reinsert_Old_Element : declare
1330 function New_Node return Node_Access;
1331 pragma Inline (New_Node);
1333 procedure Insert_Post is
1334 new Element_Keys.Generic_Insert_Post (New_Node);
1337 new Element_Keys.Generic_Conditional_Insert (Insert_Post);
1343 function New_Node return Node_Access is
1348 Result : Node_Access;
1351 -- Start of processing for Reinsert_Old_Element
1356 Key => Node.Element.all,
1358 Success => Inserted); -- TODO: change name of formal param
1362 end Reinsert_Old_Element;
1364 raise Program_Error;
1365 end Replace_Element;
1367 procedure Replace_Element
1372 Tree : Tree_Type renames Position.Container.Tree'Unrestricted_Access.all;
1375 if Position.Node = null then
1376 raise Constraint_Error;
1379 if Position.Container /= Container'Unrestricted_Access then
1380 raise Program_Error;
1383 Replace_Element (Tree, Position.Node, By);
1384 end Replace_Element;
1386 ---------------------
1387 -- Reverse_Iterate --
1388 ---------------------
1390 procedure Reverse_Iterate
1392 Process : not null access procedure (Position : Cursor))
1394 procedure Process_Node (Node : Node_Access);
1395 pragma Inline (Process_Node);
1397 procedure Local_Reverse_Iterate is
1398 new Tree_Operations.Generic_Reverse_Iteration (Process_Node);
1404 procedure Process_Node (Node : Node_Access) is
1406 Process (Cursor'(Container'Unrestricted_Access, Node));
1409 T : Tree_Type renames Container.Tree'Unrestricted_Access.all;
1410 B : Natural renames T.Busy;
1412 -- Start of processing for Reverse_Iterate
1418 Local_Reverse_Iterate (T);
1426 end Reverse_Iterate;
1432 function Right (Node : Node_Access) return Node_Access is
1441 procedure Set_Color (Node : Node_Access; Color : Color_Type) is
1443 Node.Color := Color;
1450 procedure Set_Left (Node : Node_Access; Left : Node_Access) is
1459 procedure Set_Parent (Node : Node_Access; Parent : Node_Access) is
1461 Node.Parent := Parent;
1468 procedure Set_Right (Node : Node_Access; Right : Node_Access) is
1470 Node.Right := Right;
1473 --------------------------
1474 -- Symmetric_Difference --
1475 --------------------------
1477 procedure Symmetric_Difference (Target : in out Set; Source : Set) is
1479 Set_Ops.Symmetric_Difference (Target.Tree, Source.Tree);
1480 end Symmetric_Difference;
1482 function Symmetric_Difference (Left, Right : Set) return Set is
1483 Tree : constant Tree_Type :=
1484 Set_Ops.Symmetric_Difference (Left.Tree, Right.Tree);
1486 return Set'(Controlled with Tree);
1487 end Symmetric_Difference;
1493 procedure Union (Target : in out Set; Source : Set) is
1495 Set_Ops.Union (Target.Tree, Source.Tree);
1498 function Union (Left, Right : Set) return Set is
1499 Tree : constant Tree_Type :=
1500 Set_Ops.Union (Left.Tree, Right.Tree);
1502 return Set'(Controlled with Tree);
1510 (Stream : access Root_Stream_Type'Class;
1513 procedure Write_Node
1514 (Stream : access Root_Stream_Type'Class;
1515 Node : Node_Access);
1516 pragma Inline (Write_Node);
1519 new Tree_Operations.Generic_Write (Write_Node);
1525 procedure Write_Node
1526 (Stream : access Root_Stream_Type'Class;
1530 Element_Type'Output (Stream, Node.Element.all);
1533 -- Start of processing for Write
1536 Write (Stream, Container.Tree);
1539 end Ada.Containers.Indefinite_Ordered_Sets;