summaryrefslogtreecommitdiff
path: root/src/directed_graphs.ads
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2020-04-29 00:20:09 +1000
committerJed Barber <jjbarber@y7mail.com>2020-04-29 00:20:09 +1000
commit0966aadcc0e95ddb1fc5e3edfbefe0aaf64d2f76 (patch)
tree68366ef8fa601454b92fa804b145975028d1870f /src/directed_graphs.ads
parent2551080276e30000767a318c1896db1eaa506fcc (diff)
Rough refactor of Cursors and Iterators
Diffstat (limited to 'src/directed_graphs.ads')
-rw-r--r--src/directed_graphs.ads25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/directed_graphs.ads b/src/directed_graphs.ads
index 77d9850..7039d76 100644
--- a/src/directed_graphs.ads
+++ b/src/directed_graphs.ads
@@ -682,9 +682,8 @@ private
type Cursor is record
Container : Graph_Access;
- Node : Node_Type := Node_Type'First;
- Visited : Node_Vectors.Vector;
- Path_Up : Node_Vectors.Vector;
+ Place : Node_Maps.Cursor;
+ Sub_Index : Node_Vectors.Extended_Index;
end record;
procedure Write
@@ -698,10 +697,9 @@ private
for Cursor'Read use Read;
No_Element : constant Cursor :=
- (Container => null,
- Node => Node_Type'First,
- Visited => Node_Vectors.Empty_Vector,
- Path_Up => Node_Vectors.Empty_Vector);
+ (Container => null,
+ Place => Node_Maps.No_Element,
+ Sub_Index => Node_Vectors.Extended_Index'First);
@@ -811,10 +809,10 @@ private
type Subgraph_Iterator is new Ada.Finalization.Limited_Controlled and
- Graph_Iterator_Interfaces.Forward_Iterator with
+ Graph_Iterator_Interfaces.Reversible_Iterator with
record
Container : Graph_Access;
- Root_Node : Node_Type;
+ Nodes : Node_Vectors.Vector;
end record
with Disable_Controlled => not Impl.T_Check;
@@ -825,11 +823,20 @@ private
(Object : in Subgraph_Iterator)
return Cursor;
+ overriding function Last
+ (Object : in Subgraph_Iterator)
+ return Cursor;
+
overriding function Next
(Object : in Subgraph_Iterator;
Position : in Cursor)
return Cursor;
+ overriding function Previous
+ (Object : in Subgraph_Iterator;
+ Position : in Cursor)
+ return Cursor;
+
end Directed_Graphs;