Intel(R) Threading Building Blocks Doxygen Documentation  version 4.2.3
tbb::interface9::internal::range_vector< T, MaxCapacity > Class Template Reference

Range pool stores ranges of type T in a circular buffer with MaxCapacity. More...

#include <partitioner.h>

Collaboration diagram for tbb::interface9::internal::range_vector< T, MaxCapacity >:

Public Member Functions

 range_vector (const T &elem)
 initialize via first range in pool More...
 
 ~range_vector ()
 
bool empty () const
 
depth_t size () const
 
void split_to_fill (depth_t max_depth)
 
void pop_back ()
 
void pop_front ()
 
T & back ()
 
T & front ()
 
depth_t front_depth ()
 similarly to front(), returns depth of the first range in the pool More...
 
depth_t back_depth ()
 
bool is_divisible (depth_t max_depth)
 

Private Attributes

depth_t my_head
 
depth_t my_tail
 
depth_t my_size
 
depth_t my_depth [MaxCapacity]
 
tbb::aligned_space< T, MaxCapacity > my_pool
 

Detailed Description

template<typename T, depth_t MaxCapacity>
class tbb::interface9::internal::range_vector< T, MaxCapacity >

Range pool stores ranges of type T in a circular buffer with MaxCapacity.

Definition at line 155 of file partitioner.h.

Constructor & Destructor Documentation

◆ range_vector()

template<typename T , depth_t MaxCapacity>
tbb::interface9::internal::range_vector< T, MaxCapacity >::range_vector ( const T &  elem)
inline

initialize via first range in pool

Definition at line 164 of file partitioner.h.

164  : my_head(0), my_tail(0), my_size(1) {
165  my_depth[0] = 0;
166  new( static_cast<void *>(my_pool.begin()) ) T(elem);//TODO: std::move?
167  }
T * begin() const
Pointer to beginning of array.
Definition: aligned_space.h:39
tbb::aligned_space< T, MaxCapacity > my_pool
Definition: partitioner.h:160

References tbb::aligned_space< T, N >::begin().

Here is the call graph for this function:

◆ ~range_vector()

template<typename T , depth_t MaxCapacity>
tbb::interface9::internal::range_vector< T, MaxCapacity >::~range_vector ( )
inline

Definition at line 168 of file partitioner.h.

168  {
169  while( !empty() ) pop_back();
170  }

Member Function Documentation

◆ back()

template<typename T , depth_t MaxCapacity>
T& tbb::interface9::internal::range_vector< T, MaxCapacity >::back ( )
inline

Definition at line 198 of file partitioner.h.

198  {
199  __TBB_ASSERT(my_size > 0, "range_vector::back() with empty size");
200  return my_pool.begin()[my_head];
201  }
T * begin() const
Pointer to beginning of array.
Definition: aligned_space.h:39
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:169
tbb::aligned_space< T, MaxCapacity > my_pool
Definition: partitioner.h:160

References __TBB_ASSERT, and tbb::aligned_space< T, N >::begin().

Here is the call graph for this function:

◆ back_depth()

template<typename T , depth_t MaxCapacity>
depth_t tbb::interface9::internal::range_vector< T, MaxCapacity >::back_depth ( )
inline

Definition at line 211 of file partitioner.h.

211  {
212  __TBB_ASSERT(my_size > 0, "range_vector::back_depth() with empty size");
213  return my_depth[my_head];
214  }
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:169

References __TBB_ASSERT.

◆ empty()

template<typename T , depth_t MaxCapacity>
bool tbb::interface9::internal::range_vector< T, MaxCapacity >::empty ( ) const
inline

Definition at line 171 of file partitioner.h.

171 { return my_size == 0; }

◆ front()

template<typename T , depth_t MaxCapacity>
T& tbb::interface9::internal::range_vector< T, MaxCapacity >::front ( )
inline

Definition at line 202 of file partitioner.h.

202  {
203  __TBB_ASSERT(my_size > 0, "range_vector::front() with empty size");
204  return my_pool.begin()[my_tail];
205  }
T * begin() const
Pointer to beginning of array.
Definition: aligned_space.h:39
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:169
tbb::aligned_space< T, MaxCapacity > my_pool
Definition: partitioner.h:160

References __TBB_ASSERT, and tbb::aligned_space< T, N >::begin().

Here is the call graph for this function:

◆ front_depth()

template<typename T , depth_t MaxCapacity>
depth_t tbb::interface9::internal::range_vector< T, MaxCapacity >::front_depth ( )
inline

similarly to front(), returns depth of the first range in the pool

Definition at line 207 of file partitioner.h.

207  {
208  __TBB_ASSERT(my_size > 0, "range_vector::front_depth() with empty size");
209  return my_depth[my_tail];
210  }
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:169

References __TBB_ASSERT.

◆ is_divisible()

template<typename T , depth_t MaxCapacity>
bool tbb::interface9::internal::range_vector< T, MaxCapacity >::is_divisible ( depth_t  max_depth)
inline

Definition at line 215 of file partitioner.h.

215  {
216  return back_depth() < max_depth && back().is_divisible();
217  }

◆ pop_back()

template<typename T , depth_t MaxCapacity>
void tbb::interface9::internal::range_vector< T, MaxCapacity >::pop_back ( )
inline

Definition at line 186 of file partitioner.h.

186  {
187  __TBB_ASSERT(my_size > 0, "range_vector::pop_back() with empty size");
188  my_pool.begin()[my_head].~T();
189  my_size--;
190  my_head = (my_head + MaxCapacity - 1) % MaxCapacity;
191  }
T * begin() const
Pointer to beginning of array.
Definition: aligned_space.h:39
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:169
tbb::aligned_space< T, MaxCapacity > my_pool
Definition: partitioner.h:160

References __TBB_ASSERT, and tbb::aligned_space< T, N >::begin().

Here is the call graph for this function:

◆ pop_front()

template<typename T , depth_t MaxCapacity>
void tbb::interface9::internal::range_vector< T, MaxCapacity >::pop_front ( )
inline

Definition at line 192 of file partitioner.h.

192  {
193  __TBB_ASSERT(my_size > 0, "range_vector::pop_front() with empty size");
194  my_pool.begin()[my_tail].~T();
195  my_size--;
196  my_tail = (my_tail + 1) % MaxCapacity;
197  }
T * begin() const
Pointer to beginning of array.
Definition: aligned_space.h:39
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:169
tbb::aligned_space< T, MaxCapacity > my_pool
Definition: partitioner.h:160

References __TBB_ASSERT, and tbb::aligned_space< T, N >::begin().

Here is the call graph for this function:

◆ size()

template<typename T , depth_t MaxCapacity>
depth_t tbb::interface9::internal::range_vector< T, MaxCapacity >::size ( ) const
inline

Definition at line 172 of file partitioner.h.

◆ split_to_fill()

template<typename T , depth_t MaxCapacity>
void tbb::interface9::internal::range_vector< T, MaxCapacity >::split_to_fill ( depth_t  max_depth)
inline

Populates range pool via ranges up to max depth or while divisible max_depth starts from 0, e.g. value 2 makes 3 ranges in the pool up to two 1/4 pieces

Definition at line 175 of file partitioner.h.

175  {
176  while( my_size < MaxCapacity && is_divisible(max_depth) ) {
177  depth_t prev = my_head;
178  my_head = (my_head + 1) % MaxCapacity;
179  new(my_pool.begin()+my_head) T(my_pool.begin()[prev]); // copy TODO: std::move?
180  my_pool.begin()[prev].~T(); // instead of assignment
181  new(my_pool.begin()+prev) T(my_pool.begin()[my_head], split()); // do 'inverse' split
182  my_depth[my_head] = ++my_depth[prev];
183  my_size++;
184  }
185  }
T * begin() const
Pointer to beginning of array.
Definition: aligned_space.h:39
tbb::aligned_space< T, MaxCapacity > my_pool
Definition: partitioner.h:160
bool is_divisible(depth_t max_depth)
Definition: partitioner.h:215

References tbb::aligned_space< T, N >::begin().

Here is the call graph for this function:

Member Data Documentation

◆ my_depth

template<typename T , depth_t MaxCapacity>
depth_t tbb::interface9::internal::range_vector< T, MaxCapacity >::my_depth[MaxCapacity]
private

Definition at line 159 of file partitioner.h.

◆ my_head

template<typename T , depth_t MaxCapacity>
depth_t tbb::interface9::internal::range_vector< T, MaxCapacity >::my_head
private

Definition at line 156 of file partitioner.h.

◆ my_pool

template<typename T , depth_t MaxCapacity>
tbb::aligned_space<T, MaxCapacity> tbb::interface9::internal::range_vector< T, MaxCapacity >::my_pool
private

Definition at line 160 of file partitioner.h.

◆ my_size

template<typename T , depth_t MaxCapacity>
depth_t tbb::interface9::internal::range_vector< T, MaxCapacity >::my_size
private

Definition at line 158 of file partitioner.h.

◆ my_tail

template<typename T , depth_t MaxCapacity>
depth_t tbb::interface9::internal::range_vector< T, MaxCapacity >::my_tail
private

Definition at line 157 of file partitioner.h.


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

Copyright © 2005-2019 Intel Corporation. All Rights Reserved.

Intel, Pentium, Intel Xeon, Itanium, Intel XScale and VTune are registered trademarks or trademarks of Intel Corporation or its subsidiaries in the United States and other countries.

* Other names and brands may be claimed as the property of others.