]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Add Ada 2022 Key function to sets containers
authorBob Duff <duff@adacore.com>
Tue, 24 May 2022 17:03:21 +0000 (13:03 -0400)
committerPierre-Marie de Rodat <derodat@adacore.com>
Mon, 4 Jul 2022 07:45:55 +0000 (07:45 +0000)
This patch adds the new Generic_Keys.Key function to the set children
of Ada.Containers.

gcc/ada/

* libgnat/a-cbhase.ads, libgnat/a-cborse.ads,
libgnat/a-cihase.ads, libgnat/a-ciorse.ads,
libgnat/a-cohase.ads, libgnat/a-coorse.ads (Key): New function
that takes a Container parameter, implemented as an expression
function, so it is self explanatory (doesn't need a comment).

gcc/ada/libgnat/a-cbhase.ads
gcc/ada/libgnat/a-cborse.ads
gcc/ada/libgnat/a-cihase.ads
gcc/ada/libgnat/a-ciorse.ads
gcc/ada/libgnat/a-cohase.ads
gcc/ada/libgnat/a-coorse.ads

index 7079c51741824f3cd82207e39fd4ca917787d839..351014d302f0aab96010b95839b218e1dd33568b 100644 (file)
@@ -403,6 +403,9 @@ is
       --  Applies generic formal operation Key to the element of the node
       --  designated by Position.
 
+      function Key (Container : Set; Position : Cursor) return Key_Type is
+        (Key (Element (Container, Position)));
+
       function Element (Container : Set; Key : Key_Type) return Element_Type;
       --  Searches (as per the key-based Find) for the node containing Key, and
       --  returns the associated element.
index be22c250714b3dbf1675683a77633053d08d0584..53acf355a620c390e139a3678b381149b3d22c71 100644 (file)
@@ -262,6 +262,9 @@ is
 
       function Key (Position : Cursor) return Key_Type;
 
+      function Key (Container : Set; Position : Cursor) return Key_Type is
+        (Key (Element (Container, Position)));
+
       function Element (Container : Set; Key : Key_Type) return Element_Type;
 
       procedure Replace
index dcd1d6a86fa11efc21e47a17611492e09ee69f26..2bb452729fd3713ada27dcf53fd17fa990887232 100644 (file)
@@ -389,6 +389,9 @@ is
       --  Applies generic formal operation Key to the element of the node
       --  designated by Position.
 
+      function Key (Container : Set; Position : Cursor) return Key_Type is
+        (Key (Element (Container, Position)));
+
       function Element (Container : Set; Key : Key_Type) return Element_Type;
       --  Searches (as per the key-based Find) for the node containing Key, and
       --  returns the associated element.
index d053ac72649ed53bb58568755179d7b7506db59f..51545d62e992d7ae824760d052e06774e0fb4661 100644 (file)
@@ -270,6 +270,9 @@ is
 
       function Key (Position : Cursor) return Key_Type;
 
+      function Key (Container : Set; Position : Cursor) return Key_Type is
+        (Key (Element (Container, Position)));
+
       function Element (Container : Set; Key : Key_Type) return Element_Type;
 
       procedure Replace
index 9f562d899b9e3a580b9233ee1719f83771e2a520..fb7dccaf931416ff2ce3f8e3d931b3c8fe1269d5 100644 (file)
@@ -401,6 +401,9 @@ is
       --  Applies generic formal operation Key to the element of the node
       --  designated by Position.
 
+      function Key (Container : Set; Position : Cursor) return Key_Type is
+        (Key (Element (Container, Position)));
+
       function Element (Container : Set; Key : Key_Type) return Element_Type;
       --  Searches (as per the key-based Find) for the node containing Key, and
       --  returns the associated element.
index 9619599a5b73143cad46e13f8735918fd0ff30b7..7596ed698f5103e4a4487175d90832c6a5edd713 100644 (file)
@@ -263,6 +263,9 @@ is
 
       function Key (Position : Cursor) return Key_Type;
 
+      function Key (Container : Set; Position : Cursor) return Key_Type is
+        (Key (Element (Container, Position)));
+
       function Element (Container : Set; Key : Key_Type) return Element_Type;
 
       procedure Replace