From 2551080276e30000767a318c1896db1eaa506fcc Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Tue, 28 Apr 2020 20:54:48 +1000 Subject: Switched over to Ordered_Maps --- src/directed_graphs.ads | 42 +++++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 23 deletions(-) (limited to 'src/directed_graphs.ads') diff --git a/src/directed_graphs.ads b/src/directed_graphs.ads index 854bf8e..77d9850 100644 --- a/src/directed_graphs.ads +++ b/src/directed_graphs.ads @@ -9,7 +9,7 @@ private with Ada.Containers.Helpers, Ada.Finalization, Ada.Streams, - Ada.Containers.Hashed_Maps, + Ada.Containers.Ordered_Maps, Ada.Containers.Vectors; @@ -21,6 +21,10 @@ generic type Node_Label_Type is private; type Edge_Label_Type is private; + with function "=" + (Left, Right : in Node_Type) + return Boolean is <>; + with function "=" (Left, Right : in Node_Label_Type) return Boolean is <>; @@ -50,6 +54,10 @@ package Directed_Graphs is type Edge_Array is array (Positive range <>) of Edge_Type; + function "<" + (Left, Right : in Edge_Type) + return Boolean; + @@ -619,40 +627,28 @@ private (Index_Type => Positive, Element_Type => Node_Type); - package Vector_Sort is new Node_Vectors.Generic_Sorting; + function "=" + (Left, Right : in Node_Vectors.Vector) + return Boolean renames Node_Vectors."="; + + package Node_Sort is new Node_Vectors.Generic_Sorting; package Edge_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => Edge_Type); - function To_Hash - (Node : in Node_Type) - return Ada.Containers.Hash_Type; - - function To_Hash - (Edge : in Edge_Type) - return Ada.Containers.Hash_Type; - - package Node_Maps is new Ada.Containers.Hashed_Maps + package Node_Maps is new Ada.Containers.Ordered_Maps (Key_Type => Node_Type, Element_Type => Node_Vectors.Vector, - Hash => To_Hash, - Equivalent_Keys => "=", "=" => Node_Vectors."="); - package Node_Label_Maps is new Ada.Containers.Hashed_Maps + package Node_Label_Maps is new Ada.Containers.Ordered_Maps (Key_Type => Node_Type, - Element_Type => Node_Label_Type, - Hash => To_Hash, - Equivalent_Keys => "=", - "=" => "="); + Element_Type => Node_Label_Type); - package Edge_Label_Maps is new Ada.Containers.Hashed_Maps + package Edge_Label_Maps is new Ada.Containers.Ordered_Maps (Key_Type => Edge_Type, - Element_Type => Edge_Label_Type, - Hash => To_Hash, - Equivalent_Keys => "=", - "=" => "="); + Element_Type => Edge_Label_Type); -- cgit