OSDN Git Service

2009-04-08 Thomas Quinot <quinot@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / a-rbtgso.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT LIBRARY COMPONENTS                          --
4 --                                                                          --
5 --           ADA.CONTAINERS.RED_BLACK_TREES.GENERIC_SET_OPERATIONS          --
6 --                                                                          --
7 --                                 S p e c                                  --
8 --                                                                          --
9 --          Copyright (C) 2004-2007, Free Software Foundation, Inc.         --
10 --                                                                          --
11 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
12 -- terms of the  GNU General Public License as published  by the Free Soft- --
13 -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
14 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
17 -- for  more details.  You should have  received  a copy of the GNU General --
18 -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
19 -- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
20 -- Boston, MA 02110-1301, USA.                                              --
21 --                                                                          --
22 -- As a special exception,  if other files  instantiate  generics from this --
23 -- unit, or you link  this unit with other files  to produce an executable, --
24 -- this  unit  does not  by itself cause  the resulting  executable  to  be --
25 -- covered  by the  GNU  General  Public  License.  This exception does not --
26 -- however invalidate  any other reasons why  the executable file  might be --
27 -- covered by the  GNU Public License.                                      --
28 --                                                                          --
29 -- This unit was originally developed by Matthew J Heaney.                  --
30 ------------------------------------------------------------------------------
31
32 --  Tree_Type is used to implement ordered containers. This package declares
33 --  set-based tree operations.
34
35 with Ada.Containers.Red_Black_Trees.Generic_Operations;
36
37 generic
38    with package Tree_Operations is new Generic_Operations (<>);
39
40    use Tree_Operations.Tree_Types;
41
42    with procedure Insert_With_Hint
43      (Dst_Tree : in out Tree_Type;
44       Dst_Hint : Node_Access;
45       Src_Node : Node_Access;
46       Dst_Node : out Node_Access);
47
48    with function Copy_Tree (Source_Root : Node_Access)
49        return Node_Access;
50
51    with procedure Delete_Tree (X : in out Node_Access);
52
53    with function Is_Less (Left, Right : Node_Access) return Boolean;
54
55    with procedure Free (X : in out Node_Access);
56
57 package Ada.Containers.Red_Black_Trees.Generic_Set_Operations is
58    pragma Pure;
59
60    procedure Union (Target : in out Tree_Type; Source : Tree_Type);
61    --  Attempts to insert each element of Source in Target. If Target is
62    --  busy then Program_Error is raised. We say "attempts" here because
63    --  if these are unique-element sets, then the insertion should fail
64    --  (not insert a new item) when the insertion item from Source is
65    --  equivalent to an item already in Target. If these are multisets
66    --  then of course the attempt should always succeed.
67
68    function Union (Left, Right : Tree_Type) return Tree_Type;
69    --  Makes a copy of Left, and attempts to insert each element of
70    --  Right into the copy, then returns the copy.
71
72    procedure Intersection (Target : in out Tree_Type; Source : Tree_Type);
73    --  Removes elements from Target that are not equivalent to items in
74    --  Source. If Target is busy then Program_Error is raised.
75
76    function Intersection (Left, Right : Tree_Type) return Tree_Type;
77    --  Returns a set comprising all the items in Left equivalent to items in
78    --  Right.
79
80    procedure Difference (Target : in out Tree_Type; Source : Tree_Type);
81    --  Removes elements from Target that are equivalent to items in Source. If
82    --  Target is busy then Program_Error is raised.
83
84    function Difference (Left, Right : Tree_Type) return Tree_Type;
85    --  Returns a set comprising all the items in Left not equivalent to items
86    --  in Right.
87
88    procedure Symmetric_Difference
89      (Target : in out Tree_Type;
90       Source : Tree_Type);
91    --  Removes from Target elements that are equivalent to items in Source, and
92    --  inserts into Target items from Source not equivalent elements in
93    --  Target. If Target is busy then Program_Error is raised.
94
95    function Symmetric_Difference (Left, Right : Tree_Type) return Tree_Type;
96    --  Returns a set comprising the union of the elements in Left not
97    --  equivalent to items in Right, and the elements in Right not equivalent
98    --  to items in Left.
99
100    function Is_Subset (Subset : Tree_Type; Of_Set : Tree_Type) return Boolean;
101    --  Returns False if Subset contains at least one element not equivalent to
102    --  any item in Of_Set; returns True otherwise.
103
104    function Overlap (Left, Right : Tree_Type) return Boolean;
105    --  Returns True if at least one element of Left is equivalent to an item in
106    --  Right; returns False otherwise.
107
108 end Ada.Containers.Red_Black_Trees.Generic_Set_Operations;