Can _Cilk_for iterate on STL maps?

Can _Cilk_for iterate on STL maps?


I have this loop iterating over a std::map:
for(std::map::const_iterator it = MyMap.begin(); it != MyMap.end(); it++)
No insertions/deletions are performer within the loop. Instead, values are just read from the tree as it is traversed.
1) Is random-access to elements and loop count computation at constant time mandatory?
2) Is it safe to use _Cilk_for on this loop?
2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Hi Jorge,

This kind of loop won't work with a cilk_for. You'll get the following compiler error:

 error: no operator "-" matches these operands

This is because cilk_for needs to be able to randomly access the container elements so it can dynamically split ranges in half as it spawns out work to be done in parallel.

Leave a Comment

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