summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2020-04-29 21:09:46 +1000
committerJed Barber <jjbarber@y7mail.com>2020-04-29 21:09:46 +1000
commitf499d6f1e4d4ac73a4b9fcc42d3ab9281e4f5265 (patch)
tree2b7bdcfe9741fa7e06cad2b897d8617b3308463c
parent933970ba647117d0c5fe1f4d6c6e66429c2e3ce2 (diff)
Removed Key_Vector helper function, moved Node_Array type inside package
-rw-r--r--src/directed_graphs.adb39
-rw-r--r--src/directed_graphs.ads8
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
@@ -12,20 +12,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;
with package Type_Vectors is new Ada.Containers.Vectors
(Index_Type => Positive,
@@ -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;
+