MADNESS
0.10.1
|
Range, vaguely a la Intel TBB, to encapsulate a random-access, STL-like start and end iterator with chunksize. More...
#include <range.h>
Public Types | |
using | iterator = iteratorT |
Alias for the iterator type. More... | |
Public Member Functions | |
Range (const iterator &start, const iterator &finish, int chunk=1) | |
Makes the range [start, finish). More... | |
Range (const Range &r) | |
Copy constructor. Cost is O(1). More... | |
Range (Range &left, const Split &) | |
Splits range between new and old (r) objects. Cost is O(1). More... | |
const iterator & | begin () const |
Access the beginning. More... | |
bool | empty () const |
Returns true if size == 0 . More... | |
const iterator & | end () const |
Access the end. More... | |
unsigned int | get_chunksize () const |
Access the chunk size. More... | |
bool | is_divisible () const |
Return true if this iteration range can be divided; that is, there are more items than the chunk size. More... | |
size_t | size () const |
Returns the number of items in the range (cost is O(1)). More... | |
Static Private Member Functions | |
template<typename integralT , typename distanceT > | |
static std::enable_if< std::is_integral< integralT >::value, void >::type | advance (integralT &i, distanceT n) |
Advance by n elements in the range. More... | |
template<typename iterT , typename distanceT > | |
static std::enable_if<!std::is_integral< iterT >::value, void >::type | advance (iterT &it, distanceT n) |
Advance by n elements in the range. More... | |
template<class integralT > | |
static std::enable_if< std::is_integral< integralT >::value, integralT >::type | distance (integralT first, integralT last) |
Calculate the distance between two iterators. More... | |
template<class iterT > | |
static auto | distance (iterT first, iterT last, typename std::enable_if<!std::is_integral< iterT >::value >::type *=nullptr) -> decltype(std::distance(first, last)) |
Calculate the distance between two iterators. More... | |
Private Attributes | |
int | chunksize |
Number of items to give to each thread/process. More... | |
iteratorT | finish |
Last item for iteration (first past the end, conventionally). More... | |
long | n |
Number of items to iterator over. More... | |
iteratorT | start |
First item for iteration. More... | |
Range, vaguely a la Intel TBB, to encapsulate a random-access, STL-like start and end iterator with chunksize.
iteratorT | The iterator type. |
using madness::Range< iteratorT >::iterator = iteratorT |
Alias for the iterator type.
|
inline |
Makes the range [start, finish).
The motivated reader should look at the Intel TBB range, partitioner, split, concepts, etc.
[in] | start | The first item to iterate over. |
[in] | finish | The last item for iteration (one past the end). |
[in] | chunk | The number of items to give to each thread/process. |
References madness::Range< iteratorT >::chunksize.
|
inline |
|
inline |
Splits range between new and old (r) objects. Cost is O(1).
[in] | left | The range to be split. |
References madness::Range< iteratorT >::advance(), madness::Range< iteratorT >::chunksize, madness::Range< iteratorT >::finish, madness::Range< iteratorT >::n, and madness::Range< iteratorT >::start.
|
inlinestaticprivate |
Advance by n
elements in the range.
This version is for cases where the "iterator type" is integral.
integralT | The integral iterator type. |
distanceT | The distance type. |
[in,out] | i | The integral iterator. |
[in] | n | The number of elements to advance. |
References madness::Range< iteratorT >::n.
Referenced by madness::Range< iteratorT >::Range().
|
inlinestaticprivate |
Advance by n
elements in the range.
This version is for cases where the "iterator type" is not integral.
iterT | The non-integral iterator type. |
distanceT | The distance type. |
[in,out] | it | The iterator. |
[in] | n | The number of elements to advance. |
References std::advance(), and madness::Range< iteratorT >::n.
|
inline |
Access the beginning.
References madness::Range< iteratorT >::start.
|
inlinestaticprivate |
Calculate the distance between two iterators.
This version is for cases where the "iterator type" is integral.
integralT | The integral iterator type. |
[in] | first | One iterator. |
[in] | last | The other iterator. |
|
inlinestaticprivate |
Calculate the distance between two iterators.
This version is for cases where the "iterator type" is not integral.
iterT | The non-integral iterator type. |
[in] | first | One iterator. |
[in] | last | The other iterator. |
References std::distance().
|
inline |
|
inline |
Access the end.
References madness::Range< iteratorT >::finish.
|
inline |
Access the chunk size.
long
, or size_t
? References madness::Range< iteratorT >::chunksize.
|
inline |
Return true if this iteration range can be divided; that is, there are more items than the chunk size.
References madness::Range< iteratorT >::chunksize, and madness::Range< iteratorT >::n.
|
inline |
Returns the number of items in the range (cost is O(1)).
References madness::Range< iteratorT >::n.
Referenced by split().
|
private |
Number of items to give to each thread/process.
Referenced by madness::Range< iteratorT >::Range(), madness::Range< iteratorT >::get_chunksize(), and madness::Range< iteratorT >::is_divisible().
|
private |
Last item for iteration (first past the end, conventionally).
Referenced by madness::Range< iteratorT >::Range(), and madness::Range< iteratorT >::end().
|
private |
Number of items to iterator over.
Referenced by madness::Range< iteratorT >::Range(), madness::Range< iteratorT >::advance(), madness::Range< iteratorT >::empty(), madness::Range< iteratorT >::is_divisible(), and madness::Range< iteratorT >::size().
|
private |
First item for iteration.
Referenced by madness::Range< iteratorT >::Range(), and madness::Range< iteratorT >::begin().