index of keys in concurrent hash map

index of keys in concurrent hash map

Hi

I am using tbb's concurrent hash maps and I am wondering if there is someway to find out the index of a key in the map.

So for example i declare my map like this

typedef tbb::concurrent_hash_map< openvdb::Coord, int, MyHashCompare> single_map;

where openvdb::Coord is a unique co-ordinate in the R3 /(3D)/[x,y,z] space.

Now i want to know after i have stored the co-ordinates in parallel along with a value (int) against each co-ordinate (say its weight for example) I wish to know what is the index. One way is to serially iterate over it and say store it as the first value in a vector of ints (instead of thevalue being a single int i can use a vector of ints).

Is there a way to find out the index of each key in parallel for example with a const_accessor

so using 

single_map trymap

/populate the trymap in parallel using a tbb::parallel_for 

single_map::const_accessor sc;

trymap.find(sc,some_key) 

I wish to find the index of some_key in the trymap. Is it possible or should i make a mapping by serially going through the map using an iterator. I am not particularly good at TBB so please do not mind if my question sounds too naive or childish.

Thanks again for your time.

Rohit

 

 

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Hi Rohit,

I am not sure that I understand the question. In my opinion, an indexing system supposes some ordering. The concurrent_hash_map is a hash map, i.e. it is an unordered container and cannot guarantee any order. In other words, any access to the container can cause rehashing and reordering elements inside the container. Could you describe the algorithm idea to better understand your needs, please?

Regards,
Alex

Leave a Comment

Please sign in to add a comment. Not a member? Join today