Threads::BlockedRange< T > Class Template Reference
#include <threads.h>
Public Types | |
| typedef T | const_iterator |
Public Member Functions | |
| BlockedRange (const unsigned int grainsize=1000) | |
| BlockedRange (const const_iterator first, const const_iterator last, const unsigned int grainsize=1000) | |
| BlockedRange (const BlockedRange< T > &r) | |
| BlockedRange (BlockedRange< T > &r, Threads::split) | |
| void | reset (const const_iterator first, const const_iterator last) |
| const_iterator | begin () const |
| const_iterator | end () const |
| unsigned int | grainsize () const |
| void | grainsize (const unsigned int &gs) |
| int | size () const |
| bool | empty () const |
| bool | is_divisible () const |
Private Attributes | |
| const_iterator | _end |
| const_iterator | _begin |
| unsigned int | _grainsize |
Detailed Description
template<typename T>
class Threads::BlockedRange< T >
Blocked range which can be subdivided and executed in parallel.
Definition at line 304 of file threads.h.
Member Typedef Documentation
| typedef T Threads::BlockedRange< T >::const_iterator |
Allows an StoredRange to behave like an STL container.
Constructor & Destructor Documentation
| Threads::BlockedRange< T >::BlockedRange | ( | const unsigned int | grainsize = 1000 |
) | [inline] |
Constructor. Optionally takes the grainsize parameter, which is the smallest chunk the range may be broken into for parallel execution.
Definition at line 317 of file threads.h.
00317 : 00318 _grainsize(grainsize) 00319 {}
| Threads::BlockedRange< T >::BlockedRange | ( | const const_iterator | first, | |
| const const_iterator | last, | |||
| const unsigned int | grainsize = 1000 | |||
| ) | [inline] |
Constructor. Takes the beginning and end of the range. Optionally takes the grainsize parameter, which is the smallest chunk the range may be broken into for parallel execution.
Definition at line 327 of file threads.h.
References Threads::BlockedRange< T >::reset().
00329 : 00330 _grainsize(grainsize) 00331 { 00332 this->reset(first, last); 00333 }
| Threads::BlockedRange< T >::BlockedRange | ( | const BlockedRange< T > & | r | ) | [inline] |
Copy constructor. The StoredRange can be copied into subranges for parallel execution. In this way the initial StoredRange can be thought of as the root of a binary tree. The root element is the only element which interacts with the user. It takes a specified range of objects and packs it into a contiguous vector which can be split efficiently. However, there is no need for the child ranges to contain this vector, so long as the parent outlives the children. So we implement the copy constructor to specifically omit the _objs vector.
Definition at line 348 of file threads.h.
00348 : 00349 _end(r._end), 00350 _begin(r._begin), 00351 _grainsize(r._grainsize) 00352 {}
| Threads::BlockedRange< T >::BlockedRange | ( | BlockedRange< T > & | r, | |
| Threads::split | ||||
| ) | [inline] |
Splits the range r. The first half of the range is left in place, the second half of the range is placed in *this.
Definition at line 359 of file threads.h.
References Threads::BlockedRange< T >::_begin, and Threads::BlockedRange< T >::_end.
00359 : 00360 _end(r._end), 00361 _begin(r._begin), 00362 _grainsize(r._grainsize) 00363 { 00364 const_iterator 00365 beginning = r._begin, 00366 ending = r._end, 00367 middle = beginning + (ending - beginning)/2u; 00368 00369 r._end = _begin = middle; 00370 }
Member Function Documentation
| const_iterator Threads::BlockedRange< T >::begin | ( | ) | const [inline] |
Beginning of the range.
Definition at line 385 of file threads.h.
References Threads::BlockedRange< T >::_begin.
00385 { return _begin; }
| bool Threads::BlockedRange< T >::empty | ( | ) | const [inline] |
Returns true if the range is empty.
Definition at line 415 of file threads.h.
References Threads::BlockedRange< T >::_begin, and Threads::BlockedRange< T >::_end.
| const_iterator Threads::BlockedRange< T >::end | ( | ) | const [inline] |
End of the range.
Definition at line 390 of file threads.h.
References Threads::BlockedRange< T >::_end.
00390 { return _end; }
| void Threads::BlockedRange< T >::grainsize | ( | const unsigned int & | gs | ) | [inline] |
Set the grain size.
Definition at line 401 of file threads.h.
References Threads::BlockedRange< T >::_grainsize.
00401 {_grainsize = gs;}
| unsigned int Threads::BlockedRange< T >::grainsize | ( | ) | const [inline] |
The grain size for the range. The range will be subdivided into subranges not to exceed the grain size.
Definition at line 396 of file threads.h.
References Threads::BlockedRange< T >::_grainsize.
Referenced by Threads::BlockedRange< T >::is_divisible().
00396 {return _grainsize;}
| bool Threads::BlockedRange< T >::is_divisible | ( | ) | const [inline] |
Returns true if the range can be subdivided.
Definition at line 420 of file threads.h.
References Threads::BlockedRange< T >::_begin, Threads::BlockedRange< T >::_end, and Threads::BlockedRange< T >::grainsize().
| void Threads::BlockedRange< T >::reset | ( | const const_iterator | first, | |
| const const_iterator | last | |||
| ) | [inline] |
Resets the StoredRange to contain [first,last).
Definition at line 375 of file threads.h.
References Threads::BlockedRange< T >::_begin, and Threads::BlockedRange< T >::_end.
Referenced by Threads::BlockedRange< T >::BlockedRange().
| int Threads::BlockedRange< T >::size | ( | ) | const [inline] |
- Returns:
- the size of the range.
Definition at line 406 of file threads.h.
References Threads::BlockedRange< T >::_begin, and Threads::BlockedRange< T >::_end.
Member Data Documentation
const_iterator Threads::BlockedRange< T >::_begin [private] |
Definition at line 425 of file threads.h.
Referenced by Threads::BlockedRange< T >::begin(), Threads::BlockedRange< T >::BlockedRange(), Threads::BlockedRange< T >::empty(), Threads::BlockedRange< T >::is_divisible(), Threads::BlockedRange< T >::reset(), and Threads::BlockedRange< T >::size().
const_iterator Threads::BlockedRange< T >::_end [private] |
Definition at line 424 of file threads.h.
Referenced by Threads::BlockedRange< T >::BlockedRange(), Threads::BlockedRange< T >::empty(), Threads::BlockedRange< T >::end(), Threads::BlockedRange< T >::is_divisible(), Threads::BlockedRange< T >::reset(), and Threads::BlockedRange< T >::size().
unsigned int Threads::BlockedRange< T >::_grainsize [private] |
The documentation for this class was generated from the following file: