1 ------------------------------------------------------------------------------
3 -- GNAT LIBRARY COMPONENTS --
5 -- A D A . C O N T A I N E R S . R E D _ B L A C K _ T R E E S . --
6 -- G E N E R I C _ S E T _ O P E R A T I O N S --
10 -- Copyright (C) 2004-2006, Free Software Foundation, Inc. --
12 -- GNAT is free software; you can redistribute it and/or modify it under --
13 -- terms of the GNU General Public License as published by the Free Soft- --
14 -- ware Foundation; either version 2, or (at your option) any later ver- --
15 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
16 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
17 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
18 -- for more details. You should have received a copy of the GNU General --
19 -- Public License distributed with GNAT; see file COPYING. If not, write --
20 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
21 -- Boston, MA 02110-1301, USA. --
23 -- As a special exception, if other files instantiate generics from this --
24 -- unit, or you link this unit with other files to produce an executable, --
25 -- this unit does not by itself cause the resulting executable to be --
26 -- covered by the GNU General Public License. This exception does not --
27 -- however invalidate any other reasons why the executable file might be --
28 -- covered by the GNU Public License. --
30 -- This unit was originally developed by Matthew J Heaney. --
31 ------------------------------------------------------------------------------
33 -- Tree_Type is used to implement ordered containers. This package declares
34 -- set-based tree operations.
36 with Ada.Containers.Red_Black_Trees.Generic_Operations;
39 with package Tree_Operations is new Generic_Operations (<>);
41 use Tree_Operations.Tree_Types;
43 with procedure Insert_With_Hint
44 (Dst_Tree : in out Tree_Type;
45 Dst_Hint : Node_Access;
46 Src_Node : Node_Access;
47 Dst_Node : out Node_Access);
49 with function Copy_Tree (Source_Root : Node_Access)
52 with procedure Delete_Tree (X : in out Node_Access);
54 with function Is_Less (Left, Right : Node_Access) return Boolean;
56 with procedure Free (X : in out Node_Access);
58 package Ada.Containers.Red_Black_Trees.Generic_Set_Operations is
61 procedure Union (Target : in out Tree_Type; Source : Tree_Type);
62 -- Attempts to insert each element of Source in Target. If Target is
63 -- busy then Program_Error is raised. We say "attempts" here because
64 -- if these are unique-element sets, then the insertion should fail
65 -- (not insert a new item) when the insertion item from Source is
66 -- equivalent to an item already in Target. If these are multisets
67 -- then of course the attempt should always succeed.
69 function Union (Left, Right : Tree_Type) return Tree_Type;
70 -- Makes a copy of Left, and attempts to insert each element of
71 -- Right into the copy, then returns the copy.
73 procedure Intersection (Target : in out Tree_Type; Source : Tree_Type);
74 -- Removes elements from Target that are not equivalent to items in
75 -- Source. If Target is busy then Program_Error is raised.
77 function Intersection (Left, Right : Tree_Type) return Tree_Type;
78 -- Returns a set comprising all the items in Left equivalent to items in
81 procedure Difference (Target : in out Tree_Type; Source : Tree_Type);
82 -- Removes elements from Target that are equivalent to items in Source. If
83 -- Target is busy then Program_Error is raised.
85 function Difference (Left, Right : Tree_Type) return Tree_Type;
86 -- Returns a set comprising all the items in Left not equivalent to items
89 procedure Symmetric_Difference
90 (Target : in out Tree_Type;
92 -- Removes from Target elements that are equivalent to items in Source, and
93 -- inserts into Target items from Source not equivalent elements in
94 -- Target. If Target is busy then Program_Error is raised.
96 function Symmetric_Difference (Left, Right : Tree_Type) return Tree_Type;
97 -- Returns a set comprising the union of the elements in Left not
98 -- equivalent to items in Right, and the elements in Right not equivalent
101 function Is_Subset (Subset : Tree_Type; Of_Set : Tree_Type) return Boolean;
102 -- Returns False if Subset contains at least one element not equivalent to
103 -- any item in Of_Set; returns True otherwise.
105 function Overlap (Left, Right : Tree_Type) return Boolean;
106 -- Returns True if at least one element of Left is equivalent to an item in
107 -- Right; returns False otherwise.
109 end Ada.Containers.Red_Black_Trees.Generic_Set_Operations;