summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2020-04-24 21:21:07 +1000
committerJed Barber <jjbarber@y7mail.com>2020-04-24 21:21:07 +1000
commit01a397b9c565e60171434e2b2d0d694d8a54b1e8 (patch)
tree95de04873063a8e5ae51d191059cc9fcebdd05e0
parent4b561d99f9c871e5874721592984cb427d6cbe36 (diff)
Library skeleton now compiles, with skeleton-related warnings
-rw-r--r--design_notes.txt2
-rw-r--r--directed_graph.gpr23
-rw-r--r--src/directed_graphs.adb (renamed from src/ada-containers-directed_graphs.adb)103
-rw-r--r--src/directed_graphs.ads (renamed from src/ada-containers-directed_graphs.ads)50
4 files changed, 103 insertions, 75 deletions
diff --git a/design_notes.txt b/design_notes.txt
index 9004090..f559c7c 100644
--- a/design_notes.txt
+++ b/design_notes.txt
@@ -9,7 +9,7 @@ package structure:
-Ada.Containers.Directed_Graphs
+Directed_Graphs
- generic over discrete node type, array of node type, node label type, edge label type
- implemented using the adjacancy list method
- allows both nodes and edges to be labeled, one arbitrary type for each
diff --git a/directed_graph.gpr b/directed_graph.gpr
new file mode 100644
index 0000000..d21ae6f
--- /dev/null
+++ b/directed_graph.gpr
@@ -0,0 +1,23 @@
+
+
+library project Directed_Graph is
+
+
+ for Languages use ("Ada");
+
+
+ for Source_Dirs use ("src");
+ for Object_Dir use "obj";
+ for Library_Dir use "lib";
+ for Library_Name use "dgraph";
+ for Library_Kind use "dynamic";
+
+
+ package Compiler is
+ for Default_Switches("Ada") use ("-gnaty4aAbcefhiklM100nprt");
+ end Compiler;
+
+
+end Directed_Graph;
+
+
diff --git a/src/ada-containers-directed_graphs.adb b/src/directed_graphs.adb
index 51728dd..00d8f03 100644
--- a/src/ada-containers-directed_graphs.adb
+++ b/src/directed_graphs.adb
@@ -1,6 +1,6 @@
-package body Ada.Containers.Directed_Graphs is
+package body Directed_Graphs is
pragma Warnings (Off, "variable ""Busy*"" is not referenced");
@@ -112,14 +112,14 @@ package body Ada.Containers.Directed_Graphs is
Node : in Node_Type)
return Node_Array is
begin
- return (others => False);
+ return N : Node_Array (1 .. 0);
end Children;
function Children
(Position : in Cursor)
return Node_Array is
begin
- return (others => False);
+ return N : Node_Array (1 .. 0);
end Children;
@@ -170,7 +170,7 @@ package body Ada.Containers.Directed_Graphs is
return Node_Label_Constant_Reference is
begin
return R : Node_Label_Constant_Reference :=
- (Element => null;
+ (Element => null,
Control => (Ada.Finalization.Controlled with null));
end Constant_Label_Reference;
@@ -180,7 +180,7 @@ package body Ada.Containers.Directed_Graphs is
return Edge_Label_Constant_Reference is
begin
return R : Edge_Label_Constant_Reference :=
- (Element => null;
+ (Element => null,
Control => (Ada.Finalization.Controlled with null));
end Constant_Label_Reference;
@@ -360,16 +360,16 @@ package body Ada.Containers.Directed_Graphs is
function Degree
(Container : in Graph;
Node : in Node_Type)
- return Count_Type is
+ return Ada.Containers.Count_Type is
begin
- return Count_Type'First;
+ return Ada.Containers.Count_Type'First;
end Degree;
function Degree
(Position : in Cursor)
- return Count_Type is
+ return Ada.Containers.Count_Type is
begin
- return Count_Type'First;
+ return Ada.Containers.Count_Type'First;
end Degree;
@@ -462,9 +462,9 @@ package body Ada.Containers.Directed_Graphs is
function Edge_Count
(Container : in Graph)
- return Count_Type is
+ return Ada.Containers.Count_Type is
begin
- return Count_Type'First;
+ return Ada.Containers.Count_Type'First;
end Edge_Count;
@@ -478,7 +478,7 @@ package body Ada.Containers.Directed_Graphs is
(Container : in Graph)
return Edge_Array is
begin
- return (others => False);
+ return E : Edge_Array (1 .. 0);
end Edges;
@@ -518,7 +518,7 @@ package body Ada.Containers.Directed_Graphs is
Label : in Node_Label_Type)
return Node_Array is
begin
- return (others => False);
+ return N : Node_Array (1 .. 0);
end Find;
function Find
@@ -526,7 +526,7 @@ package body Ada.Containers.Directed_Graphs is
Label : in Edge_Label_Type)
return Edge_Array is
begin
- return (others => False);
+ return E : Edge_Array (1 .. 0);
end Find;
@@ -541,7 +541,7 @@ package body Ada.Containers.Directed_Graphs is
Label : in Node_Label_Type)
return Node_Array is
begin
- return (others => False);
+ return N : Node_Array (1 .. 0);
end Find_In_Subgraph;
function Find_In_Subgraph
@@ -549,7 +549,7 @@ package body Ada.Containers.Directed_Graphs is
Label : in Edge_Label_Type)
return Edge_Array is
begin
- return (others => False);
+ return E : Edge_Array (1 .. 0);
end Find_In_Subgraph;
@@ -702,14 +702,14 @@ package body Ada.Containers.Directed_Graphs is
Node : in Node_Type)
return Edge_Array is
begin
- return (others => False);
+ return E : Edge_Array (1 .. 0);
end Inbound;
function Inbound
(Position : in Cursor)
return Edge_Array is
begin
- return (others => False);
+ return E : Edge_Array (1 .. 0);
end Inbound;
@@ -722,16 +722,16 @@ package body Ada.Containers.Directed_Graphs is
function Indegree
(Container : in Graph;
Node : in Node_Type)
- return Count_Type is
+ return Ada.Containers.Count_Type is
begin
- return Count_Type'First;
+ return Ada.Containers.Count_Type'First;
end Indegree;
function Indegree
(Position : in Cursor)
- return Count_Type is
+ return Ada.Containers.Count_Type is
begin
- return Count_Type'First;
+ return Ada.Containers.Count_Type'First;
end Indegree;
@@ -848,14 +848,14 @@ package body Ada.Containers.Directed_Graphs is
Node : in Node_Type)
return Node_Label_Type is
begin
- return Node_Label_Type'(others => <>);
+ return N : Node_Label_Type;
end Label;
function Label
(Position : in Cursor)
return Node_Label_Type is
begin
- return Node_Label_Type'(others => <>);
+ return N : Node_Label_Type;
end Label;
function Label
@@ -863,7 +863,7 @@ package body Ada.Containers.Directed_Graphs is
Edge : in Edge_Type)
return Edge_Label_Type is
begin
- return Edge_Label_Type'(others => <>);
+ return E : Edge_Label_Type;
end Label;
@@ -879,7 +879,7 @@ package body Ada.Containers.Directed_Graphs is
return Node_Label_Reference is
begin
return R : Node_Label_Reference :=
- (Element => null;
+ (Element => null,
Control => (Ada.Finalization.Controlled with null));
end Label_Reference;
@@ -888,7 +888,7 @@ package body Ada.Containers.Directed_Graphs is
return Node_Label_Reference is
begin
return R : Node_Label_Reference :=
- (Element => null;
+ (Element => null,
Control => (Ada.Finalization.Controlled with null));
end Label_Reference;
@@ -898,7 +898,7 @@ package body Ada.Containers.Directed_Graphs is
return Edge_Label_Reference is
begin
return R : Edge_Label_Reference :=
- (Element => null;
+ (Element => null,
Control => (Ada.Finalization.Controlled with null));
end Label_Reference;
@@ -974,14 +974,14 @@ package body Ada.Containers.Directed_Graphs is
Node : in Node_Type)
return Node_Array is
begin
- return (others => False);
+ return N : Node_Array (1 .. 0);
end Neighbors;
function Neighbors
(Position : in Cursor)
return Node_Array is
begin
- return (others => False);
+ return N : Node_Array (1 .. 0);
end Neighbors;
@@ -1029,9 +1029,9 @@ package body Ada.Containers.Directed_Graphs is
function Node_Count
(Container : in Graph)
- return Count_Type is
+ return Ada.Containers.Count_Type is
begin
- return Count_Type'First;
+ return Ada.Containers.Count_Type'First;
end Node_Count;
@@ -1043,8 +1043,8 @@ package body Ada.Containers.Directed_Graphs is
procedure Node_Range
(Container : in Graph;
- Minimum : out Node;
- Maximum : out Node) is
+ Minimum : out Node_Type;
+ Maximum : out Node_Type) is
begin
null;
end Node_Range;
@@ -1060,7 +1060,7 @@ package body Ada.Containers.Directed_Graphs is
(Container : in Graph)
return Node_Array is
begin
- return (others => False);
+ return N : Node_Array (1 .. 0);
end Nodes;
@@ -1075,14 +1075,14 @@ package body Ada.Containers.Directed_Graphs is
Node : in Node_Type)
return Edge_Array is
begin
- return (others => False);
+ return E : Edge_Array (1 .. 0);
end Outbound;
function Outbound
(Position : in Cursor)
return Edge_Array is
begin
- return (others => False);
+ return E : Edge_Array (1 .. 0);
end Outbound;
@@ -1095,16 +1095,16 @@ package body Ada.Containers.Directed_Graphs is
function Outdegree
(Container : in Graph;
Node : in Node_Type)
- return Count_Type is
+ return Ada.Containers.Count_Type is
begin
- return Count_Type'First;
+ return Ada.Containers.Count_Type'First;
end Outdegree;
function Outdegree
(Position : in Cursor)
- return Count_Type is
+ return Ada.Containers.Count_Type is
begin
- return Count_Type'First;
+ return Ada.Containers.Count_Type'First;
end Outdegree;
@@ -1119,14 +1119,14 @@ package body Ada.Containers.Directed_Graphs is
Node : in Node_Type)
return Node_Array is
begin
- return (others => False);
+ return N : Node_Array (1 .. 0);
end Parents;
function Parents
(Position : in Cursor)
return Node_Array is
begin
- return (others => False);
+ return N : Node_Array (1 .. 0);
end Parents;
@@ -1266,7 +1266,10 @@ package body Ada.Containers.Directed_Graphs is
function To_Cursor
(Container : in Graph;
Node : in Node_Type)
- return Cursor;
+ return Cursor is
+ begin
+ return No_Element;
+ end To_Cursor;
@@ -1292,16 +1295,16 @@ package body Ada.Containers.Directed_Graphs is
function To_Hash
(Node : in Node_Type)
- return Hash_Type is
+ return Ada.Containers.Hash_Type is
begin
- return Hash_Type'First;
+ return Ada.Containers.Hash_Type'First;
end To_Hash;
function To_Hash
(Edge : in Edge_Type)
- return Hash_Type is
+ return Ada.Containers.Hash_Type is
begin
- return Hash_Type'First;
+ return Ada.Containers.Hash_Type'First;
end To_Hash;
@@ -1316,7 +1319,7 @@ package body Ada.Containers.Directed_Graphs is
Count : in Positive := 1)
return Node_Array is
begin
- return (others => False);
+ return N : Node_Array (1 .. 0);
end Unused_Nodes;
@@ -1369,6 +1372,6 @@ package body Ada.Containers.Directed_Graphs is
end Write;
-end Ada.Containers.Directed_Graphs;
+end Directed_Graphs;
diff --git a/src/ada-containers-directed_graphs.ads b/src/directed_graphs.ads
index f248bd6..98b19af 100644
--- a/src/ada-containers-directed_graphs.ads
+++ b/src/directed_graphs.ads
@@ -16,7 +16,7 @@ private with
generic
type Node_Type is (<>);
- type Node_Array is array (Positive) of Node_Type;
+ type Node_Array is array (Positive range <>) of Node_Type;
type Node_Label_Type is private;
type Edge_Label_Type is private;
@@ -29,14 +29,14 @@ generic
(Left, Right : in Edge_Label_Type)
return Boolean is <>;
-package Ada.Containers.Directed_Graphs is
+package Directed_Graphs is
subtype Path is Node_Array;
subtype Extended_Node_Type is Node_Type'Base
- range Node_Type'First - 1 ..
- Node_Type'Min (Node_Type'Base'Last - 1, Node_Type'Last) + 1;
+ 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;
@@ -48,7 +48,7 @@ package Ada.Containers.Directed_Graphs is
To : Node_Type;
end record;
- type Edge_Array is array (Positive) of Edge_Type;
+ type Edge_Array is array (Positive range <>) of Edge_Type;
@@ -114,11 +114,11 @@ package Ada.Containers.Directed_Graphs is
function Node_Count
(Container : in Graph)
- return Count_Type;
+ return Ada.Containers.Count_Type;
function Edge_Count
(Container : in Graph)
- return Count_Type;
+ return Ada.Containers.Count_Type;
function Nodes
(Container : in Graph)
@@ -130,8 +130,8 @@ package Ada.Containers.Directed_Graphs is
procedure Node_Range
(Container : in Graph;
- Minimum : out Node;
- Maximum : out Node);
+ Minimum : out Node_Type;
+ Maximum : out Node_Type);
function Unused_Nodes
(Container : in Graph;
@@ -391,29 +391,29 @@ package Ada.Containers.Directed_Graphs is
function Outdegree
(Container : in Graph;
Node : in Node_Type)
- return Count_Type;
+ return Ada.Containers.Count_Type;
function Outdegree
(Position : in Cursor)
- return Count_Type;
+ return Ada.Containers.Count_Type;
function Indegree
(Container : in Graph;
Node : in Node_Type)
- return Count_Type;
+ return Ada.Containers.Count_Type;
function Indegree
(Position : in Cursor)
- return Count_Type;
+ return Ada.Containers.Count_Type;
function Degree
(Container : in Graph;
Node : in Node_Type)
- return Count_Type;
+ return Ada.Containers.Count_Type;
function Degree
(Position : in Cursor)
- return Count_Type;
+ return Ada.Containers.Count_Type;
function Has_Edge
(Container : in Graph;
@@ -572,35 +572,37 @@ private
- package Impl is new Helpers.Generic_Implementation;
+ package Help renames Ada.Containers.Helpers;
+ package Impl is new Help.Generic_Implementation;
+ package Streams renames Ada.Streams;
- package Node_Vectors is new Vectors
+ package Node_Vectors is new Ada.Containers.Vectors
(Index_Type => Positive,
Element_Type => Node_Type);
function To_Hash
(Node : in Node_Type)
- return Hash_Type;
+ return Ada.Containers.Hash_Type;
function To_Hash
(Edge : in Edge_Type)
- return Hash_Type;
+ return Ada.Containers.Hash_Type;
- package Node_Maps is new Hashed_Maps
+ package Node_Maps is new Ada.Containers.Hashed_Maps
(Key_Type => Node_Type,
Element_Type => Node_Vectors.Vector,
Hash => To_Hash,
Equivalent_Keys => "=",
"=" => Node_Vectors."=");
- package Node_Label_Maps is new Hashed_Maps
+ package Node_Label_Maps is new Ada.Containers.Hashed_Maps
(Key_Type => Node_Type,
Element_Type => Node_Label_Type,
Hash => To_Hash,
Equivalent_Keys => "=",
"=" => "=");
- package Edge_Label_Maps is new Hashed_Maps
+ package Edge_Label_Maps is new Ada.Containers.Hashed_Maps
(Key_Type => Edge_Type,
Element_Type => Edge_Label_Type,
Hash => To_Hash,
@@ -614,7 +616,7 @@ private
Connections : Node_Maps.Map;
Node_Labels : Node_Label_Maps.Map;
Edge_Labels : Edge_Label_Maps.Map;
- Tamper_Info : aliased Helpers.Tamper_Counts;
+ Tamper_Info : aliased Help.Tamper_Counts;
end record;
overriding procedure Adjust
@@ -788,6 +790,6 @@ private
return Cursor;
-end Ada.Containers.Directed_Graphs;
+end Directed_Graphs;