From: piscesboy on
Is it possible to map more than one key per hash table value? For
example, if I create a hash table and I want to use a name and a date
to identify a single value in the table, that's two keys that I want
to store per entry in the table that I want to use to uniquely
identify an entry. Because one entry can share a single date, and in
that case, the second identifier, the name can be used to uniquely
identify the entry.
From: piscesboy on
On Jan 17, 2:10 am, piscesboy <oraclmas...(a)gmail.com> wrote:
> Is it possible to map more than one key per hash table value? For
> example, if I create a hash table and I want to use a name and a date
> to identify a single value in the table, that's two keys that I want
> to store per entry in the table that I want to use to uniquely
> identify an entry. Because one entry can share a single date, and in
> that case, the second identifier, the name can be used to uniquely
> identify the entry.

I thought about making a hash table of hash table entries, but maybe
that might be too inefficient?
From: Robert Uhl on
piscesboy <oraclmaster(a)gmail.com> writes:

> Is it possible to map more than one key per hash table value? For
> example, if I create a hash table and I want to use a name and a date
> to identify a single value in the table, that's two keys that I want
> to store per entry in the table that I want to use to uniquely
> identify an entry. Because one entry can share a single date, and in
> that case, the second identifier, the name can be used to uniquely
> identify the entry.

Sure, just create an 'equal hash table and key off of (list name date)
as the key. It conses on every hash lookup, but if that's acceptable...

--
Robert A. Uhl
It's the twenty-first century, for Pete's sake. If you can't have a flying car,
you should at least be able to buy a sodding ray gun. --Dan Rutter
From: Captain Obvious on
??>> Is it possible to map more than one key per hash table value? For
??>> example, if I create a hash table and I want to use a name and a date
??>> to identify a single value in the table, that's two keys that I want
??>> to store per entry in the table that I want to use to uniquely
??>> identify an entry. Because one entry can share a single date, and in
??>> that case, the second identifier, the name can be used to uniquely
??>> identify the entry.

RU> Sure, just create an 'equal hash table and key off of (list name date)

Or (cons name date).


From: Captain Obvious on
p> I thought about making a hash table of hash table entries, but maybe
p> that might be too inefficient?

There is no such thing as "too inefficient". Just do whatever is convenient,
and later, _if_ performance is a problem, you can optimize it.

There are different approaches, and it is hard to tell what is best in your
situation. If you really have any performance problems, you should try
these approaches on your data, usage patterns and on a concrete
implementation to find out what works best.