21 #ifndef __TBB_blocked_range_H 22 #define __TBB_blocked_range_H 24 #include "tbb_stddef.h" 39 template<
typename Value>
56 my_end(end_), my_begin(begin_), my_grainsize(grainsize_)
58 __TBB_ASSERT( my_grainsize>0,
"grainsize must be positive" );
62 const_iterator
begin()
const {
return my_begin;}
65 const_iterator
end()
const {
return my_end;}
70 __TBB_ASSERT( !(
end()<
begin()),
"size() unspecified if end()<begin()" );
82 bool empty()
const {
return !(my_begin<my_end);}
93 my_begin(do_split(r, split())),
94 my_grainsize(r.my_grainsize)
97 __TBB_ASSERT( !(my_begin < r.my_end) && !(r.my_end < my_begin),
"blocked_range has been split incorrectly" );
100 #if __TBB_USE_PROPORTIONAL_SPLIT_IN_BLOCKED_RANGES 109 my_begin(do_split(r, proportion)),
110 my_grainsize(r.my_grainsize)
113 __TBB_ASSERT( !(my_begin < r.my_end) && !(r.my_end < my_begin),
"blocked_range has been split incorrectly" );
121 size_type my_grainsize;
127 __TBB_ASSERT( r.
is_divisible(),
"cannot split blocked_range that is not divisible" );
128 Value middle = r.my_begin + (r.my_end - r.my_begin) / 2u;
133 #if __TBB_USE_PROPORTIONAL_SPLIT_IN_BLOCKED_RANGES 134 static Value do_split(
blocked_range& r, proportional_split& proportion )
136 __TBB_ASSERT( r.
is_divisible(),
"cannot split blocked_range that is not divisible" );
144 size_type right_part =
size_type(
float(r.
size()) *
float(proportion.right())
145 /
float(proportion.left() + proportion.right()) + 0.5f);
146 return r.my_end = Value(r.my_end - right_part);
150 template<
typename RowValue,
typename ColValue>
153 template<
typename RowValue,
typename ColValue,
typename PageValue>
A 3-dimensional range that models the Range concept.
Definition: blocked_range3d.h:32
Value const_iterator
Type of a value.
Definition: blocked_range.h:45
const_iterator begin() const
Beginning of range.
Definition: blocked_range.h:62
std::size_t size_type
Type for size of a range.
Definition: blocked_range.h:48
bool empty() const
True if range is empty.
Definition: blocked_range.h:82
A range over which to iterate.
Definition: blocked_range.h:40
const_iterator end() const
One past last value in range.
Definition: blocked_range.h:65
blocked_range(blocked_range &r, proportional_split &proportion)
Split range.
Definition: blocked_range.h:107
size_type grainsize() const
The grain size for this range.
Definition: blocked_range.h:75
size_type size() const
Size of the range.
Definition: blocked_range.h:69
blocked_range()
Construct range with default-constructed values for begin and end.
Definition: blocked_range.h:52
blocked_range(Value begin_, Value end_, size_type grainsize_=1)
Construct range over half-open interval [begin,end), with the given grainsize.
Definition: blocked_range.h:55
A 2-dimensional range that models the Range concept.
Definition: blocked_range2d.h:32
bool is_divisible() const
True if range is divisible.
Definition: blocked_range.h:86
The namespace tbb contains all components of the library.
Definition: parallel_for.h:44
blocked_range(blocked_range &r, split)
Split range.
Definition: blocked_range.h:91
static const bool is_splittable_in_proportion
Static field to support proportional split.
Definition: blocked_range.h:102