a-rbtgbo.adb, [...]: Minor reformatting.
2011-08-31 Robert Dewar <dewar@adacore.com> * a-rbtgbo.adb, alfa_test.adb: Minor reformatting. From-SVN: r178366
This commit is contained in:
parent
36b8f95fd0
commit
876d4394d2
@ -1,3 +1,7 @@
|
||||
2011-08-31 Robert Dewar <dewar@adacore.com>
|
||||
|
||||
* a-rbtgbo.adb, alfa_test.adb: Minor reformatting.
|
||||
|
||||
2011-08-31 Tristan Gingold <gingold@adacore.com>
|
||||
|
||||
* exp_ch7.ads, exp_ch7.adb (Finalization_Exception_Data): New type to
|
||||
|
@ -59,13 +59,13 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is
|
||||
"attempt to tamper with cursors (container is busy)";
|
||||
end if;
|
||||
|
||||
Tree.First := 0;
|
||||
Tree.Last := 0;
|
||||
Tree.Root := 0;
|
||||
Tree.First := 0;
|
||||
Tree.Last := 0;
|
||||
Tree.Root := 0;
|
||||
Tree.Length := 0;
|
||||
-- Tree.Busy
|
||||
-- Tree.Lock
|
||||
Tree.Free := -1;
|
||||
Tree.Free := -1;
|
||||
end Clear_Tree;
|
||||
|
||||
------------------
|
||||
@ -77,7 +77,7 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is
|
||||
Node : Count_Type)
|
||||
is
|
||||
|
||||
-- CLR p274
|
||||
-- CLR p. 274
|
||||
|
||||
X : Count_Type;
|
||||
W : Count_Type;
|
||||
@ -187,7 +187,7 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is
|
||||
(Tree : in out Tree_Type'Class;
|
||||
Node : Count_Type)
|
||||
is
|
||||
-- CLR p273
|
||||
-- CLR p. 273
|
||||
|
||||
X, Y : Count_Type;
|
||||
|
||||
@ -203,9 +203,9 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is
|
||||
end if;
|
||||
|
||||
pragma Assert (Tree.Length > 0);
|
||||
pragma Assert (Tree.Root /= 0);
|
||||
pragma Assert (Tree.Root /= 0);
|
||||
pragma Assert (Tree.First /= 0);
|
||||
pragma Assert (Tree.Last /= 0);
|
||||
pragma Assert (Tree.Last /= 0);
|
||||
pragma Assert (Parent (N (Tree.Root)) = 0);
|
||||
|
||||
pragma Assert ((Tree.Length > 1)
|
||||
@ -330,12 +330,13 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is
|
||||
Set_Right (N (Parent (N (Z))), Y);
|
||||
end if;
|
||||
|
||||
Set_Left (N (Y), Left (N (Z)));
|
||||
Set_Left (N (Y), Left (N (Z)));
|
||||
Set_Parent (N (Left (N (Y))), Y);
|
||||
Set_Right (N (Y), Z);
|
||||
Set_Right (N (Y), Z);
|
||||
|
||||
Set_Parent (N (Z), Y);
|
||||
Set_Left (N (Z), 0);
|
||||
Set_Right (N (Z), 0);
|
||||
Set_Left (N (Z), 0);
|
||||
Set_Right (N (Z), 0);
|
||||
|
||||
declare
|
||||
Y_Color : constant Color_Type := Color (N (Y));
|
||||
@ -417,13 +418,13 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is
|
||||
pragma Assert (Parent (N (Y)) /= Z);
|
||||
|
||||
Y_Parent : constant Count_Type := Parent (N (Y));
|
||||
Y_Color : constant Color_Type := Color (N (Y));
|
||||
Y_Color : constant Color_Type := Color (N (Y));
|
||||
|
||||
begin
|
||||
Set_Parent (N (Y), Parent (N (Z)));
|
||||
Set_Left (N (Y), Left (N (Z)));
|
||||
Set_Right (N (Y), Right (N (Z)));
|
||||
Set_Color (N (Y), Color (N (Z)));
|
||||
Set_Left (N (Y), Left (N (Z)));
|
||||
Set_Right (N (Y), Right (N (Z)));
|
||||
Set_Color (N (Y), Color (N (Z)));
|
||||
|
||||
if Tree.Root = Z then
|
||||
Tree.Root := Y;
|
||||
@ -443,9 +444,9 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is
|
||||
end if;
|
||||
|
||||
Set_Parent (N (Z), Y_Parent);
|
||||
Set_Color (N (Z), Y_Color);
|
||||
Set_Left (N (Z), 0);
|
||||
Set_Right (N (Z), 0);
|
||||
Set_Color (N (Z), Y_Color);
|
||||
Set_Left (N (Z), 0);
|
||||
Set_Right (N (Z), 0);
|
||||
end Delete_Swap;
|
||||
|
||||
----------
|
||||
@ -526,11 +527,10 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is
|
||||
-- node onto the head of the free store.
|
||||
|
||||
-- ???
|
||||
-- See the comments above for an optimization opportunity. If
|
||||
-- the next link for a node on the free store is negative, then
|
||||
-- this means the remaining nodes on the free store are
|
||||
-- physically contiguous, starting as the absolute value of
|
||||
-- that index value.
|
||||
-- See the comments above for an optimization opportunity. If the
|
||||
-- next link for a node on the free store is negative, then this
|
||||
-- means the remaining nodes on the free store are physically
|
||||
-- contiguous, starting as the absolute value of that index value.
|
||||
|
||||
Tree.Free := abs Tree.Free;
|
||||
|
||||
@ -587,9 +587,14 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is
|
||||
Tree.Free := Tree.Free - 1;
|
||||
end if;
|
||||
|
||||
-- When a node is allocated from the free store, its pointer components
|
||||
-- (the links to other nodes in the tree) must also be initialized (to
|
||||
-- 0, the equivalent of null). This simplifies the post-allocation
|
||||
-- handling of nodes inserted into terminal positions.
|
||||
|
||||
Set_Parent (N (Node), Parent => 0);
|
||||
Set_Left (N (Node), Left => 0);
|
||||
Set_Right (N (Node), Right => 0);
|
||||
Set_Left (N (Node), Left => 0);
|
||||
Set_Right (N (Node), Right => 0);
|
||||
end Generic_Allocate;
|
||||
|
||||
-------------------
|
||||
@ -687,9 +692,9 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is
|
||||
|
||||
Set_Color (N (Node), Black);
|
||||
|
||||
Tree.Root := Node;
|
||||
Tree.First := Node;
|
||||
Tree.Last := Node;
|
||||
Tree.Root := Node;
|
||||
Tree.First := Node;
|
||||
Tree.Last := Node;
|
||||
Tree.Length := 1;
|
||||
|
||||
for J in Count_Type range 2 .. Len loop
|
||||
@ -747,8 +752,7 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is
|
||||
procedure Process (Node : Count_Type);
|
||||
pragma Inline (Process);
|
||||
|
||||
procedure Iterate is
|
||||
new Generic_Iteration (Process);
|
||||
procedure Iterate is new Generic_Iteration (Process);
|
||||
|
||||
-------------
|
||||
-- Process --
|
||||
@ -771,7 +775,7 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is
|
||||
-----------------
|
||||
|
||||
procedure Left_Rotate (Tree : in out Tree_Type'Class; X : Count_Type) is
|
||||
-- CLR p266
|
||||
-- CLR p. 266
|
||||
|
||||
N : Nodes_Type renames Tree.Nodes;
|
||||
|
||||
@ -796,7 +800,7 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is
|
||||
Set_Right (N (Parent (N (X))), Y);
|
||||
end if;
|
||||
|
||||
Set_Left (N (Y), X);
|
||||
Set_Left (N (Y), X);
|
||||
Set_Parent (N (X), Y);
|
||||
end Left_Rotate;
|
||||
|
||||
@ -808,7 +812,7 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is
|
||||
(Tree : Tree_Type'Class;
|
||||
Node : Count_Type) return Count_Type
|
||||
is
|
||||
-- CLR p248
|
||||
-- CLR p. 248
|
||||
|
||||
X : Count_Type := Node;
|
||||
Y : Count_Type;
|
||||
@ -833,7 +837,7 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is
|
||||
(Tree : Tree_Type'Class;
|
||||
Node : Count_Type) return Count_Type
|
||||
is
|
||||
-- CLR p248
|
||||
-- CLR p. 248
|
||||
|
||||
X : Count_Type := Node;
|
||||
Y : Count_Type;
|
||||
@ -859,7 +863,7 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is
|
||||
Node : Count_Type) return Count_Type
|
||||
is
|
||||
begin
|
||||
-- CLR p249
|
||||
-- CLR p. 249
|
||||
|
||||
if Node = 0 then
|
||||
return 0;
|
||||
@ -926,7 +930,7 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is
|
||||
(Tree : in out Tree_Type'Class;
|
||||
Node : Count_Type)
|
||||
is
|
||||
-- CLR p.268
|
||||
-- CLR p. 268
|
||||
|
||||
N : Nodes_Type renames Tree.Nodes;
|
||||
|
||||
@ -1014,7 +1018,7 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is
|
||||
Set_Right (N (Parent (N (Y))), X);
|
||||
end if;
|
||||
|
||||
Set_Right (N (X), Y);
|
||||
Set_Right (N (X), Y);
|
||||
Set_Parent (N (Y), X);
|
||||
end Right_Rotate;
|
||||
|
||||
|
@ -39,15 +39,15 @@
|
||||
with Get_Alfa;
|
||||
with Put_Alfa;
|
||||
|
||||
with Alfa; use Alfa;
|
||||
with Types; use Types;
|
||||
with Alfa; use Alfa;
|
||||
with Types; use Types;
|
||||
|
||||
with Ada.Command_Line; use Ada.Command_Line;
|
||||
with Ada.Streams; use Ada.Streams;
|
||||
with Ada.Streams.Stream_IO; use Ada.Streams.Stream_IO;
|
||||
with Ada.Text_IO;
|
||||
|
||||
with GNAT.OS_Lib; use GNAT.OS_Lib;
|
||||
with GNAT.OS_Lib; use GNAT.OS_Lib;
|
||||
|
||||
procedure Alfa_Test is
|
||||
Infile : File_Type;
|
||||
|
Loading…
Reference in New Issue
Block a user