diff options
author | Jed Barber <jjbarber@y7mail.com> | 2020-05-23 15:31:27 +1000 |
---|---|---|
committer | Jed Barber <jjbarber@y7mail.com> | 2020-05-23 15:31:27 +1000 |
commit | 7f56d08907ffdd192f4b4898bfb22c1dce8f1cd0 (patch) | |
tree | 791bc8ca10d1f23226aafca9fd24c8c7612a1a02 /src/directed_graphs.ads | |
parent | 5bb4bfd85fb558380a8b06ac77d0e5b27aee1feb (diff) |
Added Iterate_By function for custom iteration
Diffstat (limited to 'src/directed_graphs.ads')
-rw-r--r-- | src/directed_graphs.ads | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/directed_graphs.ads b/src/directed_graphs.ads index d31b7c7..3154f75 100644 --- a/src/directed_graphs.ads +++ b/src/directed_graphs.ads @@ -670,6 +670,21 @@ package Directed_Graphs is Position : in Cursor) return Graph_Iterator_Interfaces.Reversible_Iterator'Class; + type Choice_Function is access function + (Position : in Cursor) + return Cursor; + + type Filter_Function is access function + (Position : in Cursor) + return Boolean; + + function Iterate_By + (Container : in Graph; + Start : in Cursor; + Chooser : in Choice_Function; + Filter : in Filter_Function := null) + return Graph_Iterator_Interfaces.Forward_Iterator'Class; + function First (Container : in Graph) return Cursor; @@ -963,6 +978,31 @@ private + type By_Iterator is new Ada.Finalization.Controlled and + Graph_Iterator_Interfaces.Forward_Iterator with + record + Container : Graph_Access; + Start : Cursor; + Chooser : Choice_Function; + Filter : Filter_Function; + end record + with Disable_Controlled => not Impl.T_Check; + + overriding procedure Finalize + (Object : in out By_Iterator); + + overriding function First + (Object : in By_Iterator) + return Cursor; + + overriding function Next + (Object : in By_Iterator; + Position : in Cursor) + return Cursor; + + + + generic type Base_Type is private; type Array_Type is array (Positive range <>) of Base_Type; |