From: Matthew Heaney <matthewjheaney@earthlink.net>
Subject: Re: Ada Hash
Date: Sun, 29 Apr 2007 18:33:08 GMT
Date: 2007-04-29T18:33:08+00:00 [thread overview]
Message-ID: <u7irvyqtu.fsf@earthlink.net> (raw)
In-Reply-To: 1177429033.247571.9090@s33g2000prh.googlegroups.com
markp <markwork66@yahoo.com> writes:
> I need to use a hash table to store data using an integer as the key.
> I would like to use Ada.Containers.Hashed_Maps. Is there a default
> hash function for an integer that I can supply to the instantiation
> and could somebody provide a quick sample piece of code to do this?
You just need an identity function, as Randy pointed out:
function Hash (N : Natural) return Hash_Type is
begin
return Hash_Type (N);
end;
If your integer subtype has negative values, then you could do something like:
function Hash is
new Unchecked_Conversion (Integer, Hash_Type);
You could also use one of the ordered forms directly. Integer subtypes have a
less-than relational operator by default, so there's nothing else you would
need to do.
next prev parent reply other threads:[~2007-04-29 18:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-24 15:37 Ada Hash markp
2007-04-24 18:12 ` Randy Brukardt
2007-04-29 18:33 ` Matthew Heaney [this message]
2007-04-29 22:55 ` Robert A Duff
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox