Parallel Iteration

The types const_range_type and range_type model the Range Concept and provide methods to access the bounds of the range, as shown in Table 5-5. The types differ only in that the bounds for a const_range_type are of type const_iterator, whereas the bounds for a range_type are of type iterator.

Use the range types in conjunction with parallel_for, parallel_reduce, and parallel_scan to iterate over pairs in a concurrent_hash_map.

Table 5-5. Concept for concurrent_hash_map range R

Pseudosignature

Semantics

R::iterator R::begin() const

First item in range

R::iterator R::end() const

One past last item in range

const_range_type range( size_t grainsize ) const

Effects: constructs a const_range_type representing all keys in the table. The grainsize parameter is in units of hash table slots. Each slot typically has only one key-value pair.

Returns: a const_range_type object for the table.

range_type range( size_t grainsize )

Returns: like const_range_type, but returns a range_type object for the table.

Get Intel Threading Building Blocks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.