-- --
-- Copyright (C) 2004-2006, Free Software Foundation, Inc. --
-- --
--- This specification is derived from the Ada Reference Manual for use with --
--- GNAT. The copyright notice above, and the license provisions that follow --
--- apply solely to the contents of the part following the private keyword. --
--- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- This unit was originally developed by Matthew J Heaney. --
------------------------------------------------------------------------------
+-- The references below to "CLR" refer to the following book, from which
+-- several of the algorithms here were adapted:
+-- Introduction to Algorithms
+-- by Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest
+-- Publisher: The MIT Press (June 18, 1990)
+-- ISBN: 0262031418
+
with System; use type System.Address;
package body Ada.Containers.Red_Black_Trees.Generic_Operations is
procedure Delete_Fixup (Tree : in out Tree_Type; Node : Node_Access) is
- -- CLR p274 ???
+ -- CLR p274
X : Node_Access := Node;
W : Node_Access;
(Tree : in out Tree_Type;
Node : Node_Access)
is
- -- CLR p273 ???
+ -- CLR p273
X, Y : Node_Access;
------------------
procedure Generic_Read
- (Stream : access Root_Stream_Type'Class;
+ (Stream : not null access Root_Stream_Type'Class;
Tree : in out Tree_Type)
is
N : Count_Type'Base;
-------------------
procedure Generic_Write
- (Stream : access Root_Stream_Type'Class;
+ (Stream : not null access Root_Stream_Type'Class;
Tree : Tree_Type)
is
procedure Process (Node : Node_Access);
procedure Left_Rotate (Tree : in out Tree_Type; X : Node_Access) is
- -- CLR p266 ???
+ -- CLR p266
Y : constant Node_Access := Right (X);
pragma Assert (Y /= null);
function Max (Node : Node_Access) return Node_Access is
- -- CLR p248 ???
+ -- CLR p248
X : Node_Access := Node;
Y : Node_Access;
function Min (Node : Node_Access) return Node_Access is
- -- CLR p248 ???
+ -- CLR p248
X : Node_Access := Node;
Y : Node_Access;
function Next (Node : Node_Access) return Node_Access is
begin
- -- CLR p249 ???
+ -- CLR p249
if Node = null then
return null;
Y := Parent (Y);
end loop;
- -- Why is this code commented out ???
-
--- if Right (X) /= Y then
--- return Y;
--- else
--- return X;
--- end if;
-
return Y;
end;
end Next;
Y := Parent (Y);
end loop;
- -- Why is this code commented out ???
-
--- if Left (X) /= Y then
--- return Y;
--- else
--- return X;
--- end if;
-
return Y;
end;
end Previous;
(Tree : in out Tree_Type;
Node : Node_Access)
is
- -- CLR p.268 ???
+ -- CLR p.268
X : Node_Access := Node;
pragma Assert (X /= null);