|
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. | |
Public Member Functions | |
| Range (const iterator &start, const iterator &finish, int chunk=1) | |
| Makes the range [start, finish). | |
| Range (const Range &r) | |
| Copy constructor. Cost is O(1). | |
| Range (Range &left, const Split &) | |
| Splits range between new and old (r) objects. Cost is O(1). | |
| const iterator & | begin () const |
| Access the beginning. | |
| bool | empty () const |
Returns true if size == 0. | |
| const iterator & | end () const |
| Access the end. | |
| unsigned int | get_chunksize () const |
| Access the chunk size. | |
| bool | is_divisible () const |
| Return true if this iteration range can be divided; that is, there are more items than the chunk size. | |
| size_t | size () const |
| Returns the number of items in the range (cost is O(1)). | |
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. | |
| 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. | |
| 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. | |
| 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. | |
Private Attributes | |
| int | chunksize |
| Number of items to give to each thread/process. | |
| iteratorT | finish |
| Last item for iteration (first past the end, conventionally). | |
| long | n |
| Number of items to iterator over. | |
| iteratorT | start |
| First item for iteration. | |
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, madness::nonlinear_vector_solver(), 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. |
References madness::nonlinear_vector_solver().
|
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(), and madness::nonlinear_vector_solver().
|
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 >::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 >::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().