Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Ada Containers

142 views
Skip to first unread message

rwil...@gmail.com

unread,
Oct 7, 2012, 3:58:41 PM10/7/12
to
Can someone please explain to me the difference between Ada.Containers.Hashed_Tables and Ada.Containers.Hashed_Maps, and when you might want to use a Hashed_Table over a Hashed_Map?

Maciej Sobczak

unread,
Oct 7, 2012, 4:40:49 PM10/7/12
to
W dniu niedziela, 7 października 2012 21:58:41 UTC+2 użytkownik rwil...@gmail.com napisał:

> Can someone please explain to me the difference between Ada.Containers.Hashed_Tables and Ada.Containers.Hashed_Maps,

Yes, it is very easy - Hashed_Tables does not exists at all, whereas Hashed_Maps is a pretty useful package. :-)

Did you perhaps meant some other package? Which one?

--
Maciej Sobczak * http://www.msobczak.com * http://www.inspirel.com

rwil...@gmail.com

unread,
Oct 7, 2012, 5:25:25 PM10/7/12
to
Do you mean doesn't exist, or cannot be used?

Here's a reference page for it:
http://www.martin.dowie.btinternet.co.uk/Containers/adabrowse/ada-containers-hash_tables.html

This page shows it in the dependency list for Hashed_Maps
http://www.martin.dowie.btinternet.co.uk/Containers/adabrowse/ada-containers-hashed_maps.html

"with Ada.Containers.Hash_Tables;"

rwil...@gmail.com

unread,
Oct 7, 2012, 5:30:15 PM10/7/12
to
Maby I caused some confusion earlier with a type. I misspelled the package name. It's Ada.Containers.Hash_Tables not Ada.Containers.Hashed_Tables.

Georg Bauhaus

unread,
Oct 7, 2012, 5:56:35 PM10/7/12
to
On 07.10.12 23:30, rwil...@gmail.com wrote:
> Maby I caused some confusion earlier with a type. I misspelled the package name. It's Ada.Containers.Hash_Tables not Ada.Containers.Hashed_Tables.
>

In GNAT, package Ada.Containers.Hash_Tables
"declares the hash-table type used to implement hashed containers."

In Ada, the hashed containers are Ada.Containers.Hashed_Maps
and Ada.Containers.Hashed_Sets, and variants like Bounded_*
(new in Ada 2012) and Indefinite_*. So Hash_Tables is part of
GNAT's implementation of Ada's hashed containers, perhaps for
use by implementers only.

(You can see in the sources of GNAT's implementation of
Ada's library, this context clause in Ada.Containers.Hashed_Maps:

(private with Ada.Containers.Hash_Tables;)

Simon Wright

unread,
Oct 7, 2012, 6:00:21 PM10/7/12
to
Ada.Containers.Hash_Tables, as you noted.

Hashed_Maps is in the Standard, Hash_Tables is not; it's part of
AdaCore's implementation (and maybe others, for all I know).

GCC 4.7.0 says for Hashed_Maps

with Ada.Iterator_Interfaces;

private with Ada.Containers.Hash_Tables;
private with Ada.Finalization;
private with Ada.Streams;

generic
type Key_Type is private;
type Element_Type is private;

with function Hash (Key : Key_Type) return Hash_Type;
with function Equivalent_Keys (Left, Right : Key_Type) return Boolean;
with function "=" (Left, Right : Element_Type) return Boolean is <>;

package Ada.Containers.Hashed_Maps is

and you will see that Hash_Tables is withed privately (i.e., it's only
used in the private part, "not specified by the language").

A further clue: the comment at the start of Hash_Tables says "This
package declares the hash-table type used to implement hashed
containers."

Martin

unread,
Oct 11, 2012, 2:31:24 PM10/11/12
to
I should probably pull these pages down...that's 8 years old now and "real" versions are available.

-- Martin

georg bauhaus

unread,
Oct 12, 2012, 6:35:08 AM10/12/12
to
Martin <mar...@thedowies.com> wrote:
> I should probably pull these pages down...that's 8 years old now and
> "real" versions are available.

They are good to have if you still
run nice Ada 95 compilers.
0 new messages