1 |
12 |
jlechner |
------------------------------------------------------------------------------
|
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 _ O P E R A T I O N S --
|
7 |
|
|
-- --
|
8 |
|
|
-- S p e c --
|
9 |
|
|
-- --
|
10 |
|
|
-- Copyright (C) 2004-2005, Free Software Foundation, Inc. --
|
11 |
|
|
-- --
|
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. --
|
15 |
|
|
-- --
|
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. --
|
26 |
|
|
-- --
|
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. --
|
33 |
|
|
-- --
|
34 |
|
|
-- This unit was originally developed by Matthew J Heaney. --
|
35 |
|
|
------------------------------------------------------------------------------
|
36 |
|
|
|
37 |
|
|
with Ada.Streams; use Ada.Streams;
|
38 |
|
|
|
39 |
|
|
generic
|
40 |
|
|
with package Tree_Types is new Generic_Tree_Types (<>);
|
41 |
|
|
use Tree_Types;
|
42 |
|
|
|
43 |
|
|
with function Parent (Node : Node_Access) return Node_Access is <>;
|
44 |
|
|
with procedure Set_Parent (Node : Node_Access; Parent : Node_Access) is <>;
|
45 |
|
|
with function Left (Node : Node_Access) return Node_Access is <>;
|
46 |
|
|
with procedure Set_Left (Node : Node_Access; Left : Node_Access) is <>;
|
47 |
|
|
with function Right (Node : Node_Access) return Node_Access is <>;
|
48 |
|
|
with procedure Set_Right (Node : Node_Access; Right : Node_Access) is <>;
|
49 |
|
|
with function Color (Node : Node_Access) return Color_Type is <>;
|
50 |
|
|
with procedure Set_Color (Node : Node_Access; Color : Color_Type) is <>;
|
51 |
|
|
|
52 |
|
|
package Ada.Containers.Red_Black_Trees.Generic_Operations is
|
53 |
|
|
pragma Pure;
|
54 |
|
|
|
55 |
|
|
function Min (Node : Node_Access) return Node_Access;
|
56 |
|
|
|
57 |
|
|
function Max (Node : Node_Access) return Node_Access;
|
58 |
|
|
|
59 |
|
|
-- NOTE: The Check_Invariant operation was used during early
|
60 |
|
|
-- development of the red-black tree. Now that the tree type
|
61 |
|
|
-- implementation has matured, we don't really need Check_Invariant
|
62 |
|
|
-- anymore.
|
63 |
|
|
|
64 |
|
|
-- procedure Check_Invariant (Tree : Tree_Type);
|
65 |
|
|
|
66 |
|
|
function Vet (Tree : Tree_Type; Node : Node_Access) return Boolean;
|
67 |
|
|
|
68 |
|
|
function Next (Node : Node_Access) return Node_Access;
|
69 |
|
|
|
70 |
|
|
function Previous (Node : Node_Access) return Node_Access;
|
71 |
|
|
|
72 |
|
|
generic
|
73 |
|
|
with function Is_Equal (L, R : Node_Access) return Boolean;
|
74 |
|
|
function Generic_Equal (Left, Right : Tree_Type) return Boolean;
|
75 |
|
|
|
76 |
|
|
procedure Delete_Node_Sans_Free
|
77 |
|
|
(Tree : in out Tree_Type;
|
78 |
|
|
Node : Node_Access);
|
79 |
|
|
|
80 |
|
|
generic
|
81 |
|
|
with procedure Free (X : in out Node_Access);
|
82 |
|
|
procedure Generic_Delete_Tree (X : in out Node_Access);
|
83 |
|
|
|
84 |
|
|
generic
|
85 |
|
|
with function Copy_Node (Source : Node_Access) return Node_Access;
|
86 |
|
|
with procedure Delete_Tree (X : in out Node_Access);
|
87 |
|
|
function Generic_Copy_Tree (Source_Root : Node_Access) return Node_Access;
|
88 |
|
|
|
89 |
|
|
generic
|
90 |
|
|
with function Copy_Tree (Root : Node_Access) return Node_Access;
|
91 |
|
|
procedure Generic_Adjust (Tree : in out Tree_Type);
|
92 |
|
|
|
93 |
|
|
generic
|
94 |
|
|
with procedure Delete_Tree (X : in out Node_Access);
|
95 |
|
|
procedure Generic_Clear (Tree : in out Tree_Type);
|
96 |
|
|
|
97 |
|
|
generic
|
98 |
|
|
with procedure Clear (Tree : in out Tree_Type);
|
99 |
|
|
procedure Generic_Move (Target, Source : in out Tree_Type);
|
100 |
|
|
|
101 |
|
|
generic
|
102 |
|
|
with procedure Process (Node : Node_Access) is <>;
|
103 |
|
|
procedure Generic_Iteration (Tree : Tree_Type);
|
104 |
|
|
|
105 |
|
|
generic
|
106 |
|
|
with procedure Process (Node : Node_Access) is <>;
|
107 |
|
|
procedure Generic_Reverse_Iteration (Tree : Tree_Type);
|
108 |
|
|
|
109 |
|
|
generic
|
110 |
|
|
with procedure Write_Node
|
111 |
|
|
(Stream : access Root_Stream_Type'Class;
|
112 |
|
|
Node : Node_Access);
|
113 |
|
|
procedure Generic_Write
|
114 |
|
|
(Stream : access Root_Stream_Type'Class;
|
115 |
|
|
Tree : Tree_Type);
|
116 |
|
|
|
117 |
|
|
generic
|
118 |
|
|
with procedure Clear (Tree : in out Tree_Type);
|
119 |
|
|
with function Read_Node
|
120 |
|
|
(Stream : access Root_Stream_Type'Class) return Node_Access;
|
121 |
|
|
procedure Generic_Read
|
122 |
|
|
(Stream : access Root_Stream_Type'Class;
|
123 |
|
|
Tree : in out Tree_Type);
|
124 |
|
|
|
125 |
|
|
procedure Rebalance_For_Insert
|
126 |
|
|
(Tree : in out Tree_Type;
|
127 |
|
|
Node : Node_Access);
|
128 |
|
|
|
129 |
|
|
end Ada.Containers.Red_Black_Trees.Generic_Operations;
|