嵌套for/of
循环?像这样的东西:
Function Exists( Target, Source : Node ) return boolean is
begin
if Target = Source then
return True;
else
for List of Source loop
for Item of List loop
if Item = Target then
return True;
end if;
end loop;
end loop;
end if;
return false;
end Exists;
或者,如果您将 Vector 用于容器,则可以使用以下功能:
function Contains
(Container : Vector;
Item : Element_Type) return Boolean;
你会这样申请:
Package Inner_List is new Ada.Containers.Indefinite_Vectors(
Index_Type => Positive,
Element_Type => Integer
);
Package Outer_List is new Ada.Containers.Indefinite_Vectors(
Index_Type => Positive,
Element_Type => Inner_List.Vector,
"=" => Inner_List."="
);
Function Exists( Item : Integer; List : Outer_List.Vector ) return boolean is
begin
for Items of List loop
if Items.Contains(Item) then
return true;
end if;
end loop;
return false;
End Exists;