Commit 876d4394 by Robert Dewar Committed by Arnaud Charlet

a-rbtgbo.adb, [...]: Minor reformatting.

2011-08-31  Robert Dewar  <dewar@adacore.com>

	* a-rbtgbo.adb, alfa_test.adb: Minor reformatting.

From-SVN: r178366
parent 36b8f95f
2011-08-31 Robert Dewar <dewar@adacore.com>
* a-rbtgbo.adb, alfa_test.adb: Minor reformatting.
2011-08-31 Tristan Gingold <gingold@adacore.com> 2011-08-31 Tristan Gingold <gingold@adacore.com>
* exp_ch7.ads, exp_ch7.adb (Finalization_Exception_Data): New type to * 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 ...@@ -59,13 +59,13 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is
"attempt to tamper with cursors (container is busy)"; "attempt to tamper with cursors (container is busy)";
end if; end if;
Tree.First := 0; Tree.First := 0;
Tree.Last := 0; Tree.Last := 0;
Tree.Root := 0; Tree.Root := 0;
Tree.Length := 0; Tree.Length := 0;
-- Tree.Busy -- Tree.Busy
-- Tree.Lock -- Tree.Lock
Tree.Free := -1; Tree.Free := -1;
end Clear_Tree; end Clear_Tree;
------------------ ------------------
...@@ -77,7 +77,7 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is ...@@ -77,7 +77,7 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is
Node : Count_Type) Node : Count_Type)
is is
-- CLR p274 -- CLR p. 274
X : Count_Type; X : Count_Type;
W : Count_Type; W : Count_Type;
...@@ -187,7 +187,7 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is ...@@ -187,7 +187,7 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is
(Tree : in out Tree_Type'Class; (Tree : in out Tree_Type'Class;
Node : Count_Type) Node : Count_Type)
is is
-- CLR p273 -- CLR p. 273
X, Y : Count_Type; X, Y : Count_Type;
...@@ -203,9 +203,9 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is ...@@ -203,9 +203,9 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is
end if; end if;
pragma Assert (Tree.Length > 0); pragma Assert (Tree.Length > 0);
pragma Assert (Tree.Root /= 0); pragma Assert (Tree.Root /= 0);
pragma Assert (Tree.First /= 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 (Parent (N (Tree.Root)) = 0);
pragma Assert ((Tree.Length > 1) pragma Assert ((Tree.Length > 1)
...@@ -330,12 +330,13 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is ...@@ -330,12 +330,13 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is
Set_Right (N (Parent (N (Z))), Y); Set_Right (N (Parent (N (Z))), Y);
end if; end if;
Set_Left (N (Y), Left (N (Z))); Set_Left (N (Y), Left (N (Z)));
Set_Parent (N (Left (N (Y))), Y); Set_Parent (N (Left (N (Y))), Y);
Set_Right (N (Y), Z); Set_Right (N (Y), Z);
Set_Parent (N (Z), Y); Set_Parent (N (Z), Y);
Set_Left (N (Z), 0); Set_Left (N (Z), 0);
Set_Right (N (Z), 0); Set_Right (N (Z), 0);
declare declare
Y_Color : constant Color_Type := Color (N (Y)); Y_Color : constant Color_Type := Color (N (Y));
...@@ -417,13 +418,13 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is ...@@ -417,13 +418,13 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is
pragma Assert (Parent (N (Y)) /= Z); pragma Assert (Parent (N (Y)) /= Z);
Y_Parent : constant Count_Type := Parent (N (Y)); 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 begin
Set_Parent (N (Y), Parent (N (Z))); Set_Parent (N (Y), Parent (N (Z)));
Set_Left (N (Y), Left (N (Z))); Set_Left (N (Y), Left (N (Z)));
Set_Right (N (Y), Right (N (Z))); Set_Right (N (Y), Right (N (Z)));
Set_Color (N (Y), Color (N (Z))); Set_Color (N (Y), Color (N (Z)));
if Tree.Root = Z then if Tree.Root = Z then
Tree.Root := Y; Tree.Root := Y;
...@@ -443,9 +444,9 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is ...@@ -443,9 +444,9 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is
end if; end if;
Set_Parent (N (Z), Y_Parent); Set_Parent (N (Z), Y_Parent);
Set_Color (N (Z), Y_Color); Set_Color (N (Z), Y_Color);
Set_Left (N (Z), 0); Set_Left (N (Z), 0);
Set_Right (N (Z), 0); Set_Right (N (Z), 0);
end Delete_Swap; end Delete_Swap;
---------- ----------
...@@ -526,11 +527,10 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is ...@@ -526,11 +527,10 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is
-- node onto the head of the free store. -- node onto the head of the free store.
-- ??? -- ???
-- See the comments above for an optimization opportunity. If -- See the comments above for an optimization opportunity. If the
-- the next link for a node on the free store is negative, then -- next link for a node on the free store is negative, then this
-- this means the remaining nodes on the free store are -- means the remaining nodes on the free store are physically
-- physically contiguous, starting as the absolute value of -- contiguous, starting as the absolute value of that index value.
-- that index value.
Tree.Free := abs Tree.Free; Tree.Free := abs Tree.Free;
...@@ -587,9 +587,14 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is ...@@ -587,9 +587,14 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is
Tree.Free := Tree.Free - 1; Tree.Free := Tree.Free - 1;
end if; 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_Parent (N (Node), Parent => 0);
Set_Left (N (Node), Left => 0); Set_Left (N (Node), Left => 0);
Set_Right (N (Node), Right => 0); Set_Right (N (Node), Right => 0);
end Generic_Allocate; end Generic_Allocate;
------------------- -------------------
...@@ -687,9 +692,9 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is ...@@ -687,9 +692,9 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is
Set_Color (N (Node), Black); Set_Color (N (Node), Black);
Tree.Root := Node; Tree.Root := Node;
Tree.First := Node; Tree.First := Node;
Tree.Last := Node; Tree.Last := Node;
Tree.Length := 1; Tree.Length := 1;
for J in Count_Type range 2 .. Len loop for J in Count_Type range 2 .. Len loop
...@@ -747,8 +752,7 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is ...@@ -747,8 +752,7 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is
procedure Process (Node : Count_Type); procedure Process (Node : Count_Type);
pragma Inline (Process); pragma Inline (Process);
procedure Iterate is procedure Iterate is new Generic_Iteration (Process);
new Generic_Iteration (Process);
------------- -------------
-- Process -- -- Process --
...@@ -771,7 +775,7 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is ...@@ -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 procedure Left_Rotate (Tree : in out Tree_Type'Class; X : Count_Type) is
-- CLR p266 -- CLR p. 266
N : Nodes_Type renames Tree.Nodes; N : Nodes_Type renames Tree.Nodes;
...@@ -796,7 +800,7 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is ...@@ -796,7 +800,7 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is
Set_Right (N (Parent (N (X))), Y); Set_Right (N (Parent (N (X))), Y);
end if; end if;
Set_Left (N (Y), X); Set_Left (N (Y), X);
Set_Parent (N (X), Y); Set_Parent (N (X), Y);
end Left_Rotate; end Left_Rotate;
...@@ -808,7 +812,7 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is ...@@ -808,7 +812,7 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is
(Tree : Tree_Type'Class; (Tree : Tree_Type'Class;
Node : Count_Type) return Count_Type Node : Count_Type) return Count_Type
is is
-- CLR p248 -- CLR p. 248
X : Count_Type := Node; X : Count_Type := Node;
Y : Count_Type; Y : Count_Type;
...@@ -833,7 +837,7 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is ...@@ -833,7 +837,7 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is
(Tree : Tree_Type'Class; (Tree : Tree_Type'Class;
Node : Count_Type) return Count_Type Node : Count_Type) return Count_Type
is is
-- CLR p248 -- CLR p. 248
X : Count_Type := Node; X : Count_Type := Node;
Y : Count_Type; Y : Count_Type;
...@@ -859,7 +863,7 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is ...@@ -859,7 +863,7 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is
Node : Count_Type) return Count_Type Node : Count_Type) return Count_Type
is is
begin begin
-- CLR p249 -- CLR p. 249
if Node = 0 then if Node = 0 then
return 0; return 0;
...@@ -926,7 +930,7 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is ...@@ -926,7 +930,7 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is
(Tree : in out Tree_Type'Class; (Tree : in out Tree_Type'Class;
Node : Count_Type) Node : Count_Type)
is is
-- CLR p.268 -- CLR p. 268
N : Nodes_Type renames Tree.Nodes; N : Nodes_Type renames Tree.Nodes;
...@@ -1014,7 +1018,7 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is ...@@ -1014,7 +1018,7 @@ package body Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations is
Set_Right (N (Parent (N (Y))), X); Set_Right (N (Parent (N (Y))), X);
end if; end if;
Set_Right (N (X), Y); Set_Right (N (X), Y);
Set_Parent (N (Y), X); Set_Parent (N (Y), X);
end Right_Rotate; end Right_Rotate;
......
...@@ -39,15 +39,15 @@ ...@@ -39,15 +39,15 @@
with Get_Alfa; with Get_Alfa;
with Put_Alfa; with Put_Alfa;
with Alfa; use Alfa; with Alfa; use Alfa;
with Types; use Types; with Types; use Types;
with Ada.Command_Line; use Ada.Command_Line; with Ada.Command_Line; use Ada.Command_Line;
with Ada.Streams; use Ada.Streams; with Ada.Streams; use Ada.Streams;
with Ada.Streams.Stream_IO; use Ada.Streams.Stream_IO; with Ada.Streams.Stream_IO; use Ada.Streams.Stream_IO;
with Ada.Text_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 procedure Alfa_Test is
Infile : File_Type; Infile : File_Type;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment