From f499d6f1e4d4ac73a4b9fcc42d3ab9281e4f5265 Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Wed, 29 Apr 2020 21:09:46 +1000 Subject: Removed Key_Vector helper function, moved Node_Array type inside package --- src/directed_graphs.adb | 39 +++++---------------------------------- src/directed_graphs.ads | 8 ++++---- 2 files changed, 9 insertions(+), 38 deletions(-) diff --git a/src/directed_graphs.adb b/src/directed_graphs.adb index 3914137..7641d75 100644 --- a/src/directed_graphs.adb +++ b/src/directed_graphs.adb @@ -10,20 +10,6 @@ package body Directed_Graphs is - generic - type Base_Type is private; - type Ignore_Element is private; - with package Key_Maps is new Ada.Containers.Ordered_Maps - (Key_Type => Base_Type, - Element_Type => Ignore_Element, - others => <>); - with package Type_Vectors is new Ada.Containers.Vectors - (Index_Type => Positive, - Element_Type => Base_Type); - function Key_Vector - (My_Map : in Key_Maps.Map) - return Type_Vectors.Vector; - generic type Base_Type is private; type Array_Type is array (Positive range <>) of Base_Type; @@ -1444,24 +1430,6 @@ package body Directed_Graphs is - ---------------- - -- Key_Vector -- - ---------------- - - function Key_Vector - (My_Map : in Key_Maps.Map) - return Type_Vectors.Vector is - begin - return My_Vector : Type_Vectors.Vector do - for C in My_Map.Iterate loop - My_Vector.Append (Key_Maps.Key (C)); - end loop; - end return; - end Key_Vector; - - - - ----------- -- Label -- ----------- @@ -1865,9 +1833,12 @@ package body Directed_Graphs is return Node_Array is function V2A is new Vector_To_Array (Node_Type, Node_Array, Node_Vectors); - function Keys is new Key_Vector (Node_Type, Node_Vectors.Vector, Node_Maps, Node_Vectors); + Result : Node_Vectors.Vector; begin - return V2A (Keys (Container.Connections)); + for C in Container.Connections.Iterate loop + Result.Append (Node_Maps.Key (C)); + end loop; + return V2A (Result); end Nodes; function Nodes diff --git a/src/directed_graphs.ads b/src/directed_graphs.ads index c4d48f7..826455a 100644 --- a/src/directed_graphs.ads +++ b/src/directed_graphs.ads @@ -16,8 +16,6 @@ private with generic type Node_Type is (<>); - type Node_Array is array (Positive range <>) of Node_Type; - type Node_Label_Type is private; type Edge_Label_Type is private; @@ -36,14 +34,16 @@ generic package Directed_Graphs is - subtype Path is Node_Array; - subtype Extended_Node_Type is Node_Type'Base range Node_Type'Pred (Node_Type'First) .. Node_Type'Succ (Node_Type'Min (Node_Type'Base'Pred (Node_Type'Base'Last), Node_Type'Last)); No_Node : constant Extended_Node_Type := Extended_Node_Type'First; + type Node_Array is array (Positive range <>) of Node_Type; + + subtype Path is Node_Array; + -- cgit