comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Ada Hash
Date: Tue, 24 Apr 2007 13:12:50 -0500
Date: 2007-04-24T13:12:50-05:00	[thread overview]
Message-ID: <f0lh7h$4f9$1@jacob-sparre.dk> (raw)
In-Reply-To: 1177429033.247571.9090@s33g2000prh.googlegroups.com

"markp" <markwork66@yahoo.com> wrote in message
news:1177429033.247571.9090@s33g2000prh.googlegroups.com...
> 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?

There isn't a default function for this; but generally you don't need one -
the identity function would work fine unless your integers are distributed
unusually.

In any case, writing hash functions is an art; I generally test as many as a
dozen possibilities on sample data sets to see which one(s) work best. What
works best depends totally on your data; there is no such thing as a good
predefined hash function. (OTOH, if you don't have much data, anything might
be good enough -- but if that is true, why use the hashed container form at
all? The Ordered forms are easier to use and cost about the same on small
data sets.)

                                                Randy.






  reply	other threads:[~2007-04-24 18:12 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 [this message]
2007-04-29 18:33 ` Matthew Heaney
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