The operations Find_In_Subtree and Ancestor_Find had a Container parameter as
part of the signature (it was included in AI05-0136 by mistake), but that
parameter is not necessary, and has therefore been removed.
Tested on x86_64-pc-linux-gnu, committed on trunk
2011-08-29 Matthew Heaney <[email protected]>
* a-comutr.ads, a-comutr.adb, a-cimutr.ads, a-cimutr.adb,
a-cbmutr.ads, a-cbmutr.adb (Find_In_Subtree): Remove superfluous
Container parameter.
(Ancestor_Find): ditto.
Index: a-cimutr.adb
===================================================================
--- a-cimutr.adb (revision 178184)
+++ a-cimutr.adb (working copy)
@@ -164,22 +164,22 @@
-------------------
function Ancestor_Find
- (Container : Tree;
- Item : Element_Type;
- Position : Cursor) return Cursor
+ (Position : Cursor;
+ Item : Element_Type) return Cursor
is
- R : constant Tree_Node_Access := Root_Node (Container);
- N : Tree_Node_Access;
+ R, N : Tree_Node_Access;
begin
if Position = No_Element then
raise Constraint_Error with "Position cursor has no element";
end if;
- if Position.Container /= Container'Unrestricted_Access then
- raise Program_Error with "Position cursor not in container";
- end if;
+ -- Commented-out pending ARG ruling. ???
+ -- if Position.Container /= Container'Unrestricted_Access then
+ -- raise Program_Error with "Position cursor not in container";
+ -- end if;
+
-- AI-0136 says to raise PE if Position equals the root node. This does
-- not seem correct, as this value is just the limiting condition of the
-- search. For now we omit this check pending a ruling from the ARG.???
@@ -188,10 +188,11 @@
-- raise Program_Error with "Position cursor designates root";
-- end if;
+ R := Root_Node (Position.Container.all);
N := Position.Node;
while N /= R loop
if N.Element.all = Item then
- return Cursor'(Container'Unrestricted_Access, N);
+ return Cursor'(Position.Container, N);
end if;
N := N.Parent;
@@ -974,9 +975,8 @@
---------------------
function Find_In_Subtree
- (Container : Tree;
- Item : Element_Type;
- Position : Cursor) return Cursor
+ (Position : Cursor;
+ Item : Element_Type) return Cursor
is
Result : Tree_Node_Access;
@@ -985,10 +985,12 @@
raise Constraint_Error with "Position cursor has no element";
end if;
- if Position.Container /= Container'Unrestricted_Access then
- raise Program_Error with "Position cursor not in container";
- end if;
+ -- Commented-out pending ruling from ARG. ???
+ -- if Position.Container /= Container'Unrestricted_Access then
+ -- raise Program_Error with "Position cursor not in container";
+ -- end if;
+
if Is_Root (Position) then
Result := Find_In_Children (Position.Node, Item);
@@ -1000,7 +1002,7 @@
return No_Element;
end if;
- return Cursor'(Container'Unrestricted_Access, Result);
+ return Cursor'(Position.Container, Result);
end Find_In_Subtree;
function Find_In_Subtree
Index: a-cimutr.ads
===================================================================
--- a-cimutr.ads (revision 178155)
+++ a-cimutr.ads (working copy)
@@ -113,15 +113,37 @@
(Container : Tree;
Item : Element_Type) return Cursor;
+ -- This version of the AI:
+ -- 10-06-02 AI05-0136-1/07
+ -- declares Find_In_Subtree this way:
+ --
+ -- function Find_In_Subtree
+ -- (Container : Tree;
+ -- Item : Element_Type;
+ -- Position : Cursor) return Cursor;
+ --
+ -- It seems that the Container parameter is there by mistake, but we need
+ -- an official ruling from the ARG. ???
+
function Find_In_Subtree
- (Container : Tree;
- Item : Element_Type;
- Position : Cursor) return Cursor;
+ (Position : Cursor;
+ Item : Element_Type) return Cursor;
+ -- This version of the AI:
+ -- 10-06-02 AI05-0136-1/07
+ -- declares Ancestor_Find this way:
+ --
+ -- function Ancestor_Find
+ -- (Container : Tree;
+ -- Item : Element_Type;
+ -- Position : Cursor) return Cursor;
+ --
+ -- It seems that the Container parameter is there by mistake, but we need
+ -- an official ruling from the ARG. ???
+
function Ancestor_Find
- (Container : Tree;
- Item : Element_Type;
- Position : Cursor) return Cursor;
+ (Position : Cursor;
+ Item : Element_Type) return Cursor;
function Contains
(Container : Tree;
Index: a-comutr.adb
===================================================================
--- a-comutr.adb (revision 178184)
+++ a-comutr.adb (working copy)
@@ -163,22 +163,22 @@
-------------------
function Ancestor_Find
- (Container : Tree;
- Item : Element_Type;
- Position : Cursor) return Cursor
+ (Position : Cursor;
+ Item : Element_Type) return Cursor
is
- R : constant Tree_Node_Access := Root_Node (Container);
- N : Tree_Node_Access;
+ R, N : Tree_Node_Access;
begin
if Position = No_Element then
raise Constraint_Error with "Position cursor has no element";
end if;
- if Position.Container /= Container'Unrestricted_Access then
- raise Program_Error with "Position cursor not in container";
- end if;
+ -- Commented-out pending official ruling from ARG. ???
+ -- if Position.Container /= Container'Unrestricted_Access then
+ -- raise Program_Error with "Position cursor not in container";
+ -- end if;
+
-- AI-0136 says to raise PE if Position equals the root node. This does
-- not seem correct, as this value is just the limiting condition of the
-- search. For now we omit this check, pending a ruling from the ARG.???
@@ -187,10 +187,11 @@
-- raise Program_Error with "Position cursor designates root";
-- end if;
+ R := Root_Node (Position.Container.all);
N := Position.Node;
while N /= R loop
if N.Element = Item then
- return Cursor'(Container'Unrestricted_Access, N);
+ return Cursor'(Position.Container, N);
end if;
N := N.Parent;
@@ -950,9 +951,8 @@
---------------------
function Find_In_Subtree
- (Container : Tree;
- Item : Element_Type;
- Position : Cursor) return Cursor
+ (Position : Cursor;
+ Item : Element_Type) return Cursor
is
Result : Tree_Node_Access;
@@ -961,10 +961,12 @@
raise Constraint_Error with "Position cursor has no element";
end if;
- if Position.Container /= Container'Unrestricted_Access then
- raise Program_Error with "Position cursor not in container";
- end if;
+ -- Commented out pending official ruling by ARG. ???
+ -- if Position.Container /= Container'Unrestricted_Access then
+ -- raise Program_Error with "Position cursor not in container";
+ -- end if;
+
if Is_Root (Position) then
Result := Find_In_Children (Position.Node, Item);
@@ -976,7 +978,7 @@
return No_Element;
end if;
- return Cursor'(Container'Unrestricted_Access, Result);
+ return Cursor'(Position.Container, Result);
end Find_In_Subtree;
function Find_In_Subtree
Index: a-comutr.ads
===================================================================
--- a-comutr.ads (revision 178155)
+++ a-comutr.ads (working copy)
@@ -113,15 +113,37 @@
(Container : Tree;
Item : Element_Type) return Cursor;
+ -- This version of the AI:
+ -- 10-06-02 AI05-0136-1/07
+ -- declares Find_In_Subtree this way:
+ --
+ -- function Find_In_Subtree
+ -- (Container : Tree;
+ -- Item : Element_Type;
+ -- Position : Cursor) return Cursor;
+ --
+ -- It seems that the Container parameter is there by mistake, but we need
+ -- an official ruling from the ARG. ???
+
function Find_In_Subtree
- (Container : Tree;
- Item : Element_Type;
- Position : Cursor) return Cursor;
+ (Position : Cursor;
+ Item : Element_Type) return Cursor;
+ -- This version of the AI:
+ -- 10-06-02 AI05-0136-1/07
+ -- declares Ancestor_Find this way:
+ --
+ -- function Ancestor_Find
+ -- (Container : Tree;
+ -- Item : Element_Type;
+ -- Position : Cursor) return Cursor;
+ --
+ -- It seems that the Container parameter is there by mistake, but we need
+ -- an official ruling from the ARG. ???
+
function Ancestor_Find
- (Container : Tree;
- Item : Element_Type;
- Position : Cursor) return Cursor;
+ (Position : Cursor;
+ Item : Element_Type) return Cursor;
function Contains
(Container : Tree;
Index: a-cbmutr.adb
===================================================================
--- a-cbmutr.adb (revision 178184)
+++ a-cbmutr.adb (working copy)
@@ -286,22 +286,22 @@
-------------------
function Ancestor_Find
- (Container : Tree;
- Item : Element_Type;
- Position : Cursor) return Cursor
+ (Position : Cursor;
+ Item : Element_Type) return Cursor
is
- R : constant Count_Type := Root_Node (Container);
- N : Count_Type;
+ R, N : Count_Type;
begin
if Position = No_Element then
raise Constraint_Error with "Position cursor has no element";
end if;
- if Position.Container /= Container'Unrestricted_Access then
- raise Program_Error with "Position cursor not in container";
- end if;
+ -- Commented-out pending ruling by ARG. ???
+ -- if Position.Container /= Container'Unrestricted_Access then
+ -- raise Program_Error with "Position cursor not in container";
+ -- end if;
+
-- AI-0136 says to raise PE if Position equals the root node. This does
-- not seem correct, as this value is just the limiting condition of the
-- search. For now we omit this check, pending a ruling from the ARG.
@@ -311,13 +311,14 @@
-- raise Program_Error with "Position cursor designates root";
-- end if;
+ R := Root_Node (Position.Container.all);
N := Position.Node;
while N /= R loop
- if Container.Elements (N) = Item then
- return Cursor'(Container'Unrestricted_Access, N);
+ if Position.Container.Elements (N) = Item then
+ return Cursor'(Position.Container, N);
end if;
- N := Container.Nodes (N).Parent;
+ N := Position.Container.Nodes (N).Parent;
end loop;
return No_Element;
@@ -1289,9 +1290,8 @@
---------------------
function Find_In_Subtree
- (Container : Tree;
- Item : Element_Type;
- Position : Cursor) return Cursor
+ (Position : Cursor;
+ Item : Element_Type) return Cursor
is
Result : Count_Type;
@@ -1300,27 +1300,35 @@
raise Constraint_Error with "Position cursor has no element";
end if;
- if Position.Container /= Container'Unrestricted_Access then
- raise Program_Error with "Position cursor not in container";
- end if;
+ -- Commented-out pending ruling by ARG. ???
- if Container.Count = 0 then
+ -- if Position.Container /= Container'Unrestricted_Access then
+ -- raise Program_Error with "Position cursor not in container";
+ -- end if;
+
+ if Position.Container.Count = 0 then
pragma Assert (Is_Root (Position));
return No_Element;
end if;
if Is_Root (Position) then
- Result := Find_In_Children (Container, Position.Node, Item);
+ Result := Find_In_Children
+ (Container => Position.Container.all,
+ Subtree => Position.Node,
+ Item => Item);
else
- Result := Find_In_Subtree (Container, Position.Node, Item);
+ Result := Find_In_Subtree
+ (Container => Position.Container.all,
+ Subtree => Position.Node,
+ Item => Item);
end if;
if Result = 0 then
return No_Element;
end if;
- return Cursor'(Container'Unrestricted_Access, Result);
+ return Cursor'(Position.Container, Result);
end Find_In_Subtree;
function Find_In_Subtree
Index: a-cbmutr.ads
===================================================================
--- a-cbmutr.ads (revision 178155)
+++ a-cbmutr.ads (working copy)
@@ -113,22 +113,36 @@
Item : Element_Type) return Cursor;
-- This version of the AI:
+ -- 10-06-02 AI05-0136-1/07
+ -- declares Find_In_Subtree this way:
+ --
+ -- function Find_In_Subtree
+ -- (Container : Tree;
+ -- Item : Element_Type;
+ -- Position : Cursor) return Cursor;
+ --
+ -- It seems that the Container parameter is there by mistake, but we need
+ -- an official ruling from the ARG. ???
- -- 10-06-02 AI05-0136-1/07
+ function Find_In_Subtree
+ (Position : Cursor;
+ Item : Element_Type) return Cursor;
- -- declares Find_In_Subtree with a Container parameter, but this seems
- -- incorrect. We need a ruling from the ARG about whether this really was
- -- intended. ???
+ -- This version of the AI:
+ -- 10-06-02 AI05-0136-1/07
+ -- declares Ancestor_Find this way:
+ --
+ -- function Ancestor_Find
+ -- (Container : Tree;
+ -- Item : Element_Type;
+ -- Position : Cursor) return Cursor;
+ --
+ -- It seems that the Container parameter is there by mistake, but we need
+ -- an official ruling from the ARG. ???
- function Find_In_Subtree
- (Container : Tree;
- Item : Element_Type;
- Position : Cursor) return Cursor;
-
function Ancestor_Find
- (Container : Tree;
- Item : Element_Type;
- Position : Cursor) return Cursor;
+ (Position : Cursor;
+ Item : Element_Type) return Cursor;
function Contains
(Container : Tree;