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 151 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 160 of file partitioner.h.

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

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 164 of file partitioner.h.

164  {
165  while( !empty() ) pop_back();
166  }

Member Function Documentation

◆ back()

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

Definition at line 194 of file partitioner.h.

194  {
195  __TBB_ASSERT(my_size > 0, "range_vector::back() with empty size");
196  return my_pool.begin()[my_head];
197  }
tbb::aligned_space< T, MaxCapacity > my_pool
Definition: partitioner.h:156
T * begin() const
Pointer to beginning of array.
Definition: aligned_space.h:35
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165

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 207 of file partitioner.h.

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

References __TBB_ASSERT.

◆ empty()

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

Definition at line 167 of file partitioner.h.

167 { return my_size == 0; }

◆ front()

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

Definition at line 198 of file partitioner.h.

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

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 203 of file partitioner.h.

203  {
204  __TBB_ASSERT(my_size > 0, "range_vector::front_depth() with empty size");
205  return my_depth[my_tail];
206  }
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165

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 211 of file partitioner.h.

211  {
212  return back_depth() < max_depth && back().is_divisible();
213  }

◆ pop_back()

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

Definition at line 182 of file partitioner.h.

182  {
183  __TBB_ASSERT(my_size > 0, "range_vector::pop_back() with empty size");
184  my_pool.begin()[my_head].~T();
185  my_size--;
186  my_head = (my_head + MaxCapacity - 1) % MaxCapacity;
187  }
tbb::aligned_space< T, MaxCapacity > my_pool
Definition: partitioner.h:156
T * begin() const
Pointer to beginning of array.
Definition: aligned_space.h:35
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165

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 188 of file partitioner.h.

188  {
189  __TBB_ASSERT(my_size > 0, "range_vector::pop_front() with empty size");
190  my_pool.begin()[my_tail].~T();
191  my_size--;
192  my_tail = (my_tail + 1) % MaxCapacity;
193  }
tbb::aligned_space< T, MaxCapacity > my_pool
Definition: partitioner.h:156
T * begin() const
Pointer to beginning of array.
Definition: aligned_space.h:35
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165

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 168 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 171 of file partitioner.h.

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

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 155 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 152 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 156 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 154 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 153 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.