From: Pierre-Marie de Rodat <derodat@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Bob Duff <duff@adacore.com>
Subject: [Ada] Add Ada 2022 Key function to sets containers
Date: Mon, 4 Jul 2022 07:50:14 +0000 [thread overview]
Message-ID: <20220704075014.GA99137@adacore.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 433 bytes --]
This patch adds the new Generic_Keys.Key function to the set children
of Ada.Containers.
Tested on x86_64-pc-linux-gnu, committed on trunk
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).
[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 3210 bytes --]
diff --git a/gcc/ada/libgnat/a-cbhase.ads b/gcc/ada/libgnat/a-cbhase.ads
--- a/gcc/ada/libgnat/a-cbhase.ads
+++ b/gcc/ada/libgnat/a-cbhase.ads
@@ -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.
diff --git a/gcc/ada/libgnat/a-cborse.ads b/gcc/ada/libgnat/a-cborse.ads
--- a/gcc/ada/libgnat/a-cborse.ads
+++ b/gcc/ada/libgnat/a-cborse.ads
@@ -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
diff --git a/gcc/ada/libgnat/a-cihase.ads b/gcc/ada/libgnat/a-cihase.ads
--- a/gcc/ada/libgnat/a-cihase.ads
+++ b/gcc/ada/libgnat/a-cihase.ads
@@ -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.
diff --git a/gcc/ada/libgnat/a-ciorse.ads b/gcc/ada/libgnat/a-ciorse.ads
--- a/gcc/ada/libgnat/a-ciorse.ads
+++ b/gcc/ada/libgnat/a-ciorse.ads
@@ -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
diff --git a/gcc/ada/libgnat/a-cohase.ads b/gcc/ada/libgnat/a-cohase.ads
--- a/gcc/ada/libgnat/a-cohase.ads
+++ b/gcc/ada/libgnat/a-cohase.ads
@@ -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.
diff --git a/gcc/ada/libgnat/a-coorse.ads b/gcc/ada/libgnat/a-coorse.ads
--- a/gcc/ada/libgnat/a-coorse.ads
+++ b/gcc/ada/libgnat/a-coorse.ads
@@ -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
reply other threads:[~2022-07-04 7:50 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220704075014.GA99137@adacore.com \
--to=derodat@adacore.com \
--cc=duff@adacore.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).