473,326 Members | 2,048 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Multidimensional hash functions

Hi,

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, Valuemd_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 ?

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.
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. Does anyone know of a canned (presumeably non STL) hash map
that can utilise the original initialisation array as the actual data
storeage ?

Efficiency is important to me because I'm working on a video codec.

Many thanks,

Mike

May 24 '07 #1
1 6267
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, Valuemd_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>, Valuemd_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
May 24 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Golf Nut | last post by:
I am finding that altering and affecting values in elements in multidimensional arrays is a huge pain in the ass. I cannot seem to find a consistent way to assign values to arrays. Foreach would...
47
by: VK | last post by:
Or why I just did myArray = "Computers" but myArray.length is showing 0. What a hey? There is a new trend to treat arrays and hashes as they were some variations of the same thing. But they...
2
by: Bryan Olson | last post by:
The current Python standard library provides two cryptographic hash functions: MD5 and SHA-1 . The authors of MD5 originally stated: It is conjectured that it is computationally infeasible to...
4
by: flipdog | last post by:
Hello all, I didn't know there is a thread on hash function started in this newsgroup so reposted my posting from another group. Hope I can have some feedbacks. I am new to hash table. I came...
21
by: utab | last post by:
Hi there, Is there a way to convert a double value to a string. I know that there is fcvt() but I think this function is not a part of the standard library. I want sth from the standard if...
12
by: Arash Partow | last post by:
Hi all, I've ported various hash functions to python if anyone is interested: def RSHash(key): a = 378551 b = 63689 hash = 0
21
by: Johan Tibell | last post by:
I would be grateful if someone had a minute or two to review my hash table implementation. It's not yet commented but hopefully it's short and idiomatic enough to be readable. Some of the code...
21
by: Hallvard B Furuseth | last post by:
Is the code below valid? Generally a value must be accessed through the same type it was stored as, but there is an exception for data stored through a character type. I'm not sure if that...
139
by: ravi | last post by:
Hi can anybody tell me that which ds will be best suited to implement a hash table in C/C++ thanx. in advanced
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.