OSDN Git Service

2007-04-20 Vincent Celier <celier@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / a-rbtgso.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT LIBRARY COMPONENTS                          --
4 --                                                                          --
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                --
7 --                                                                          --
8 --                                 S p e c                                  --
9 --                                                                          --
10 --          Copyright (C) 2004-2006, Free Software Foundation, Inc.         --
11 --                                                                          --
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.                                              --
22 --                                                                          --
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.                                      --
29 --                                                                          --
30 -- This unit was originally developed by Matthew J Heaney.                  --
31 ------------------------------------------------------------------------------
32
33 --  Tree_Type is used to implement ordered containers. This package declares
34 --  set-based tree operations.
35
36 with Ada.Containers.Red_Black_Trees.Generic_Operations;
37
38 generic
39    with package Tree_Operations is new Generic_Operations (<>);
40
41    use Tree_Operations.Tree_Types;
42
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);
48
49    with function Copy_Tree (Source_Root : Node_Access)
50        return Node_Access;
51
52    with procedure Delete_Tree (X : in out Node_Access);
53
54    with function Is_Less (Left, Right : Node_Access) return Boolean;
55
56    with procedure Free (X : in out Node_Access);
57
58 package Ada.Containers.Red_Black_Trees.Generic_Set_Operations is
59    pragma Pure;
60
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.
68
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.
72
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.
76
77    function Intersection (Left, Right : Tree_Type) return Tree_Type;
78    --  Returns a set comprising all the items in Left equivalent to items in
79    --  Right.
80
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.
84
85    function Difference (Left, Right : Tree_Type) return Tree_Type;
86    --  Returns a set comprising all the items in Left not equivalent to items
87    --  in Right.
88
89    procedure Symmetric_Difference
90      (Target : in out Tree_Type;
91       Source : 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.
95
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
99    --  to items in Left.
100
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.
104
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.
108
109 end Ada.Containers.Red_Black_Trees.Generic_Set_Operations;