RobWorkProject  23.9.11-
Public Member Functions | List of all members
blocks< T1, T2, T > Class Template Reference

A helper class to divide a range into blocks. Used by parallelize_loop() and push_loop(). More...

#include <BS_thread_pool.hpp>

Public Member Functions

 blocks (const T1 first_index_, const T2 index_after_last_, const size_t num_blocks_)
 Construct a blocks object with the given specifications. More...
 
start (const size_t i) const
 Get the first index of a block. More...
 
end (const size_t i) const
 Get the index after the last index of a block. More...
 
size_t get_num_blocks () const
 Get the number of blocks. Note that this may be different than the desired number of blocks that was passed to the constructor. More...
 
size_t get_total_size () const
 Get the total number of indices in the range. More...
 

Detailed Description

template<typename T1, typename T2, typename T = std::common_type_t<T1, T2>>
class BS::blocks< T1, T2, T >

A helper class to divide a range into blocks. Used by parallelize_loop() and push_loop().

Template Parameters
T1The type of the first index in the range. Should be a signed or unsigned integer.
T2The type of the index after the last index in the range. Should be a signed or unsigned integer. If T1 is not the same as T2, a common type will be automatically inferred.
TThe common type of T1 and T2.

Constructor & Destructor Documentation

◆ blocks()

blocks ( const T1  first_index_,
const T2  index_after_last_,
const size_t  num_blocks_ 
)
inline

Construct a blocks object with the given specifications.

Parameters
first_index_The first index in the range.
index_after_last_The index after the last index in the range.
num_blocks_The desired number of blocks to divide the range into.

Member Function Documentation

◆ end()

T end ( const size_t  i) const
inline

Get the index after the last index of a block.

Parameters
iThe block number.
Returns
The index after the last index.

◆ get_num_blocks()

size_t get_num_blocks ( ) const
inline

Get the number of blocks. Note that this may be different than the desired number of blocks that was passed to the constructor.

Returns
The number of blocks.

◆ get_total_size()

size_t get_total_size ( ) const
inline

Get the total number of indices in the range.

Returns
The total number of indices.

◆ start()

T start ( const size_t  i) const
inline

Get the first index of a block.

Parameters
iThe block number.
Returns
The first index.

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