OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
threading_common::blocked_range< Value > Class Template Reference

A range over which to iterate. More...

#include <threading_std.h>

+ Collaboration diagram for threading_common::blocked_range< Value >:

Public Types

using const_iterator = Value
 Type of a value. More...
 
using size_type = std::size_t
 Type for size of a range. More...
 

Public Member Functions

 blocked_range (Value begin_, Value end_)
 Construct range over half-open interval [begin,end), with the given grainsize. More...
 
const_iterator begin () const
 Beginning of range. More...
 
const_iterator end () const
 One past last value in range. More...
 
size_type size () const
 Size of the range. More...
 
size_type grainsize () const
 The grain size for this range. More...
 
bool empty () const
 True if range is empty. More...
 
bool is_divisible () const
 True if range is divisible. More...
 
 blocked_range (blocked_range &r, split)
 Split range. More...
 

Static Private Member Functions

static Value do_split (blocked_range &r, split)
 Auxiliary function used by the splitting constructor. More...
 

Private Attributes

Value my_end
 
Value my_begin
 

Detailed Description

template<typename Value>
class threading_common::blocked_range< Value >

A range over which to iterate.

Definition at line 21 of file threading_std.h.

Member Typedef Documentation

template<typename Value>
using threading_common::blocked_range< Value >::const_iterator = Value

Type of a value.

Called a const_iterator for sake of algorithms that need to treat a blocked_range as an STL container.

Definition at line 26 of file threading_std.h.

template<typename Value>
using threading_common::blocked_range< Value >::size_type = std::size_t

Type for size of a range.

Definition at line 29 of file threading_std.h.

Constructor & Destructor Documentation

template<typename Value>
threading_common::blocked_range< Value >::blocked_range ( Value  begin_,
Value  end_ 
)
inline

Construct range over half-open interval [begin,end), with the given grainsize.

Definition at line 32 of file threading_std.h.

33  : my_end(end_)
34  , my_begin(begin_) //, my_grainsize(grainsize_)
35  {
36  // assert( my_grainsize>0 && "grainsize must be positive" );
37  }
template<typename Value>
threading_common::blocked_range< Value >::blocked_range ( blocked_range< Value > &  r,
split   
)
inline

Split range.

The new Range *this has the second part, the old range r has the first part. Unspecified if end()<begin() or !is_divisible().

Definition at line 69 of file threading_std.h.

References threading_common::blocked_range< Value >::my_begin, and threading_common::blocked_range< Value >::my_end.

70  : my_end(r.my_end)
71  , my_begin(do_split(r, split()))
72  // TODO , my_grainsize(r.my_grainsize)
73  {
74  // only comparison 'less than' is required from values of blocked_range objects
75  assert(!(my_begin < r.my_end) && !(r.my_end < my_begin) &&
76  "blocked_range has been split incorrectly");
77  }
static Value do_split(blocked_range &r, split)
Auxiliary function used by the splitting constructor.
Definition: threading_std.h:87
std::vector< std::string > split(std::string_view str, std::string_view delim, std::optional< size_t > maxsplit)
split apart a string into a vector of substrings

Member Function Documentation

template<typename Value>
const_iterator threading_common::blocked_range< Value >::begin ( ) const
inline

Beginning of range.

Definition at line 40 of file threading_std.h.

References threading_common::blocked_range< Value >::my_begin.

Referenced by threading_serial::parallel_for(), threading_std::parallel_for(), threading_serial::parallel_reduce(), threading_std::parallel_reduce(), and threading_common::blocked_range< Value >::size().

40 { return my_begin; }

+ Here is the caller graph for this function:

template<typename Value>
static Value threading_common::blocked_range< Value >::do_split ( blocked_range< Value > &  r,
split   
)
inlinestaticprivate

Auxiliary function used by the splitting constructor.

Definition at line 87 of file threading_std.h.

References threading_common::blocked_range< Value >::is_divisible(), threading_common::blocked_range< Value >::my_begin, and threading_common::blocked_range< Value >::my_end.

87  {
88  assert(r.is_divisible() && "cannot split blocked_range that is not divisible");
89  Value middle = r.my_begin + (r.my_end - r.my_begin) / 2u;
90  r.my_end = middle;
91  return middle;
92  }
bool is_divisible() const
True if range is divisible.
Definition: threading_std.h:64

+ Here is the call graph for this function:

template<typename Value>
bool threading_common::blocked_range< Value >::empty ( ) const
inline
template<typename Value>
const_iterator threading_common::blocked_range< Value >::end ( ) const
inline

One past last value in range.

Definition at line 43 of file threading_std.h.

References threading_common::blocked_range< Value >::my_end.

Referenced by threading_serial::parallel_for(), threading_std::parallel_for(), threading_serial::parallel_reduce(), threading_std::parallel_reduce(), and threading_common::blocked_range< Value >::size().

43 { return my_end; }

+ Here is the caller graph for this function:

template<typename Value>
size_type threading_common::blocked_range< Value >::grainsize ( ) const
inline

The grain size for this range.

Definition at line 53 of file threading_std.h.

53 { return 1 /*my_grainsize*/; }
template<typename Value>
bool threading_common::blocked_range< Value >::is_divisible ( ) const
inline

True if range is divisible.

Unspecified if end()<begin().

Definition at line 64 of file threading_std.h.

References threading_common::blocked_range< Value >::size().

Referenced by threading_common::blocked_range< Value >::do_split().

64 { return /*TODO my_grainsize<*/ size(); }
size_type size() const
Size of the range.
Definition: threading_std.h:47

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename Value>
size_type threading_common::blocked_range< Value >::size ( ) const
inline

Size of the range.

Unspecified if end()<begin().

Definition at line 47 of file threading_std.h.

References threading_common::blocked_range< Value >::begin(), threading_common::blocked_range< Value >::end(), threading_common::blocked_range< Value >::my_begin, and threading_common::blocked_range< Value >::my_end.

Referenced by threading_common::blocked_range< Value >::is_divisible(), threading_serial::parallel_for(), threading_std::parallel_for(), threading_serial::parallel_reduce(), and threading_std::parallel_reduce().

47  {
48  assert(!(end() < begin()) && "size() unspecified if end()<begin()");
49  return size_type(my_end - my_begin);
50  }
const_iterator end() const
One past last value in range.
Definition: threading_std.h:43
const_iterator begin() const
Beginning of range.
Definition: threading_std.h:40
std::size_t size_type
Type for size of a range.
Definition: threading_std.h:29

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation


The documentation for this class was generated from the following file: