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 _ O P E R A T I O N 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
.Streams
; use Ada
.Streams
;
40 with package Tree_Types
is new Generic_Tree_Types
(<>);
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 <>;
52 package Ada
.Containers
.Red_Black_Trees
.Generic_Operations
is
55 function Min
(Node
: Node_Access
) return Node_Access
;
57 function Max
(Node
: Node_Access
) return Node_Access
;
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
64 -- procedure Check_Invariant (Tree : Tree_Type);
66 function Vet
(Tree
: Tree_Type
; Node
: Node_Access
) return Boolean;
68 function Next
(Node
: Node_Access
) return Node_Access
;
70 function Previous
(Node
: Node_Access
) return Node_Access
;
73 with function Is_Equal
(L
, R
: Node_Access
) return Boolean;
74 function Generic_Equal
(Left
, Right
: Tree_Type
) return Boolean;
76 procedure Delete_Node_Sans_Free
77 (Tree
: in out Tree_Type
;
81 with procedure Free
(X
: in out Node_Access
);
82 procedure Generic_Delete_Tree
(X
: in out Node_Access
);
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
;
90 with function Copy_Tree
(Root
: Node_Access
) return Node_Access
;
91 procedure Generic_Adjust
(Tree
: in out Tree_Type
);
94 with procedure Delete_Tree
(X
: in out Node_Access
);
95 procedure Generic_Clear
(Tree
: in out Tree_Type
);
98 with procedure Clear
(Tree
: in out Tree_Type
);
99 procedure Generic_Move
(Target
, Source
: in out Tree_Type
);
102 with procedure Process
(Node
: Node_Access
) is <>;
103 procedure Generic_Iteration
(Tree
: Tree_Type
);
106 with procedure Process
(Node
: Node_Access
) is <>;
107 procedure Generic_Reverse_Iteration
(Tree
: Tree_Type
);
110 with procedure Write_Node
111 (Stream
: access Root_Stream_Type
'Class;
113 procedure Generic_Write
114 (Stream
: access Root_Stream_Type
'Class;
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
);
125 procedure Rebalance_For_Insert
126 (Tree
: in out Tree_Type
;
129 end Ada
.Containers
.Red_Black_Trees
.Generic_Operations
;