Intel(R) Threading Building Blocks Doxygen Documentation  version 4.2.3
tbb::internal::vector_iterator< Container, Value > Class Template Reference

Meets requirements of a forward iterator for STL and a Value for a blocked_range.*/. More...

#include <concurrent_vector.h>

Collaboration diagram for tbb::internal::vector_iterator< Container, Value >:

Public Types

typedef ptrdiff_t difference_type
 
typedef Value value_type
 
typedef Value * pointer
 
typedef Value & reference
 
typedef std::random_access_iterator_tag iterator_category
 

Public Member Functions

 vector_iterator ()
 Default constructor. More...
 
 vector_iterator (const vector_iterator< Container, typename Container::value_type > &other)
 
vector_iterator operator+ (ptrdiff_t offset) const
 
vector_iteratoroperator+= (ptrdiff_t offset)
 
vector_iterator operator- (ptrdiff_t offset) const
 
vector_iteratoroperator-= (ptrdiff_t offset)
 
Value & operator* () const
 
Value & operator[] (ptrdiff_t k) const
 
Value * operator-> () const
 
vector_iteratoroperator++ ()
 Pre increment. More...
 
vector_iteratoroperator-- ()
 Pre decrement. More...
 
vector_iterator operator++ (int)
 Post increment. More...
 
vector_iterator operator-- (int)
 Post decrement. More...
 

Private Member Functions

 vector_iterator (const Container &vector, size_t index, void *ptr=0)
 

Private Attributes

Container * my_vector
 concurrent_vector over which we are iterating. More...
 
size_t my_index
 Index into the vector. More...
 
Value * my_item
 Caches my_vector->internal_subscript(my_index) More...
 

Friends

template<typename C , typename U >
class internal::vector_iterator
 
template<typename T , class A >
class tbb::concurrent_vector
 
template<typename C , typename T >
vector_iterator< C, T > operator+ (ptrdiff_t offset, const vector_iterator< C, T > &v)
 
template<typename C , typename T , typename U >
bool operator== (const vector_iterator< C, T > &i, const vector_iterator< C, U > &j)
 
template<typename C , typename T , typename U >
bool operator< (const vector_iterator< C, T > &i, const vector_iterator< C, U > &j)
 
template<typename C , typename T , typename U >
ptrdiff_t operator- (const vector_iterator< C, T > &i, const vector_iterator< C, U > &j)
 

Detailed Description

template<typename Container, typename Value>
class tbb::internal::vector_iterator< Container, Value >

Meets requirements of a forward iterator for STL and a Value for a blocked_range.*/.

Value is either the T or const T type of the container.

Definition at line 67 of file concurrent_vector.h.

Member Typedef Documentation

◆ difference_type

template<typename Container, typename Value>
typedef ptrdiff_t tbb::internal::vector_iterator< Container, Value >::difference_type

Definition at line 418 of file concurrent_vector.h.

◆ iterator_category

template<typename Container, typename Value>
typedef std::random_access_iterator_tag tbb::internal::vector_iterator< Container, Value >::iterator_category

Definition at line 422 of file concurrent_vector.h.

◆ pointer

template<typename Container, typename Value>
typedef Value* tbb::internal::vector_iterator< Container, Value >::pointer

Definition at line 420 of file concurrent_vector.h.

◆ reference

template<typename Container, typename Value>
typedef Value& tbb::internal::vector_iterator< Container, Value >::reference

Definition at line 421 of file concurrent_vector.h.

◆ value_type

template<typename Container, typename Value>
typedef Value tbb::internal::vector_iterator< Container, Value >::value_type

Definition at line 419 of file concurrent_vector.h.

Constructor & Destructor Documentation

◆ vector_iterator() [1/3]

template<typename Container, typename Value>
tbb::internal::vector_iterator< Container, Value >::vector_iterator ( const Container &  vector,
size_t  index,
void ptr = 0 
)
inlineprivate

Definition at line 325 of file concurrent_vector.h.

325  :
326  my_vector(const_cast<Container*>(&vector)),
327  my_index(index),
328  my_item(static_cast<Value*>(ptr))
329  {}
Value * my_item
Caches my_vector->internal_subscript(my_index)
Container * my_vector
concurrent_vector over which we are iterating.
size_t my_index
Index into the vector.

◆ vector_iterator() [2/3]

template<typename Container, typename Value>
tbb::internal::vector_iterator< Container, Value >::vector_iterator ( )
inline

Default constructor.

Definition at line 333 of file concurrent_vector.h.

333 : my_vector(NULL), my_index(~size_t(0)), my_item(NULL) {}
Value * my_item
Caches my_vector->internal_subscript(my_index)
Container * my_vector
concurrent_vector over which we are iterating.
size_t my_index
Index into the vector.

◆ vector_iterator() [3/3]

template<typename Container, typename Value>
tbb::internal::vector_iterator< Container, Value >::vector_iterator ( const vector_iterator< Container, typename Container::value_type > &  other)
inline

Definition at line 335 of file concurrent_vector.h.

335  :
336  my_vector(other.my_vector),
337  my_index(other.my_index),
338  my_item(other.my_item)
339  {}
Value * my_item
Caches my_vector->internal_subscript(my_index)
Container * my_vector
concurrent_vector over which we are iterating.
size_t my_index
Index into the vector.

Member Function Documentation

◆ operator*()

template<typename Container, typename Value>
Value& tbb::internal::vector_iterator< Container, Value >::operator* ( ) const
inline

Definition at line 357 of file concurrent_vector.h.

References __TBB_ASSERT.

357  {
358  Value* item = my_item;
359  if( !item ) {
360  item = my_item = &my_vector->internal_subscript(my_index);
361  }
362  __TBB_ASSERT( item==&my_vector->internal_subscript(my_index), "corrupt cache" );
363  return *item;
364  }
Value * my_item
Caches my_vector->internal_subscript(my_index)
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165
Container * my_vector
concurrent_vector over which we are iterating.
size_t my_index
Index into the vector.

◆ operator+()

template<typename Container, typename Value>
vector_iterator tbb::internal::vector_iterator< Container, Value >::operator+ ( ptrdiff_t  offset) const
inline

Definition at line 341 of file concurrent_vector.h.

References tbb::internal::concurrent_vector_base_v3::vector_iterator.

341  {
342  return vector_iterator( *my_vector, my_index+offset );
343  }
vector_iterator()
Default constructor.
Container * my_vector
concurrent_vector over which we are iterating.
size_t my_index
Index into the vector.

◆ operator++() [1/2]

template<typename Container, typename Value>
vector_iterator& tbb::internal::vector_iterator< Container, Value >::operator++ ( )
inline

Pre increment.

Definition at line 371 of file concurrent_vector.h.

References tbb::internal::concurrent_vector_base_v3::is_first_element_in_segment().

371  {
372  size_t element_index = ++my_index;
373  if( my_item ) {
374  //TODO: consider using of knowledge about "first_block optimization" here as well?
376  //if the iterator crosses a segment boundary, the pointer become invalid
377  //as possibly next segment is in another memory location
378  my_item= NULL;
379  } else {
380  ++my_item;
381  }
382  }
383  return *this;
384  }
Value * my_item
Caches my_vector->internal_subscript(my_index)
static bool is_first_element_in_segment(size_type element_index)
size_t my_index
Index into the vector.
Here is the call graph for this function:

◆ operator++() [2/2]

template<typename Container, typename Value>
vector_iterator tbb::internal::vector_iterator< Container, Value >::operator++ ( int  )
inline

Post increment.

Definition at line 403 of file concurrent_vector.h.

403  {
404  vector_iterator result = *this;
405  operator++();
406  return result;
407  }
vector_iterator()
Default constructor.
vector_iterator & operator++()
Pre increment.

◆ operator+=()

template<typename Container, typename Value>
vector_iterator& tbb::internal::vector_iterator< Container, Value >::operator+= ( ptrdiff_t  offset)
inline

Definition at line 344 of file concurrent_vector.h.

344  {
345  my_index+=offset;
346  my_item = NULL;
347  return *this;
348  }
Value * my_item
Caches my_vector->internal_subscript(my_index)
size_t my_index
Index into the vector.

◆ operator-()

template<typename Container, typename Value>
vector_iterator tbb::internal::vector_iterator< Container, Value >::operator- ( ptrdiff_t  offset) const
inline

Definition at line 349 of file concurrent_vector.h.

References tbb::internal::concurrent_vector_base_v3::vector_iterator.

349  {
350  return vector_iterator( *my_vector, my_index-offset );
351  }
vector_iterator()
Default constructor.
Container * my_vector
concurrent_vector over which we are iterating.
size_t my_index
Index into the vector.

◆ operator--() [1/2]

template<typename Container, typename Value>
vector_iterator& tbb::internal::vector_iterator< Container, Value >::operator-- ( )
inline

Pre decrement.

Definition at line 387 of file concurrent_vector.h.

References __TBB_ASSERT, and tbb::internal::concurrent_vector_base_v3::is_first_element_in_segment().

387  {
388  __TBB_ASSERT( my_index>0, "operator--() applied to iterator already at beginning of concurrent_vector" );
389  size_t element_index = my_index--;
390  if( my_item ) {
392  //if the iterator crosses a segment boundary, the pointer become invalid
393  //as possibly next segment is in another memory location
394  my_item= NULL;
395  } else {
396  --my_item;
397  }
398  }
399  return *this;
400  }
Value * my_item
Caches my_vector->internal_subscript(my_index)
static bool is_first_element_in_segment(size_type element_index)
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165
size_t my_index
Index into the vector.
Here is the call graph for this function:

◆ operator--() [2/2]

template<typename Container, typename Value>
vector_iterator tbb::internal::vector_iterator< Container, Value >::operator-- ( int  )
inline

Post decrement.

Definition at line 410 of file concurrent_vector.h.

410  {
411  vector_iterator result = *this;
412  operator--();
413  return result;
414  }
vector_iterator()
Default constructor.
vector_iterator & operator--()
Pre decrement.

◆ operator-=()

template<typename Container, typename Value>
vector_iterator& tbb::internal::vector_iterator< Container, Value >::operator-= ( ptrdiff_t  offset)
inline

Definition at line 352 of file concurrent_vector.h.

352  {
353  my_index-=offset;
354  my_item = NULL;
355  return *this;
356  }
Value * my_item
Caches my_vector->internal_subscript(my_index)
size_t my_index
Index into the vector.

◆ operator->()

template<typename Container, typename Value>
Value* tbb::internal::vector_iterator< Container, Value >::operator-> ( ) const
inline

Definition at line 368 of file concurrent_vector.h.

368 {return &operator*();}

◆ operator[]()

template<typename Container, typename Value>
Value& tbb::internal::vector_iterator< Container, Value >::operator[] ( ptrdiff_t  k) const
inline

Definition at line 365 of file concurrent_vector.h.

365  {
366  return my_vector->internal_subscript(my_index+k);
367  }
Container * my_vector
concurrent_vector over which we are iterating.
size_t my_index
Index into the vector.

Friends And Related Function Documentation

◆ internal::vector_iterator

template<typename Container, typename Value>
template<typename C , typename U >
friend class internal::vector_iterator
friend

Definition at line 316 of file concurrent_vector.h.

◆ operator+

template<typename Container, typename Value>
template<typename C , typename T >
vector_iterator<C,T> operator+ ( ptrdiff_t  offset,
const vector_iterator< C, T > &  v 
)
friend

◆ operator-

template<typename Container, typename Value>
template<typename C , typename T , typename U >
ptrdiff_t operator- ( const vector_iterator< C, T > &  i,
const vector_iterator< C, U > &  j 
)
friend

◆ operator<

template<typename Container, typename Value>
template<typename C , typename T , typename U >
bool operator< ( const vector_iterator< C, T > &  i,
const vector_iterator< C, U > &  j 
)
friend

◆ operator==

template<typename Container, typename Value>
template<typename C , typename T , typename U >
bool operator== ( const vector_iterator< C, T > &  i,
const vector_iterator< C, U > &  j 
)
friend

◆ tbb::concurrent_vector

template<typename Container, typename Value>
template<typename T , class A >
friend class tbb::concurrent_vector
friend

Definition at line 320 of file concurrent_vector.h.

Member Data Documentation

◆ my_index

template<typename Container, typename Value>
size_t tbb::internal::vector_iterator< Container, Value >::my_index
private

◆ my_item

template<typename Container, typename Value>
Value* tbb::internal::vector_iterator< Container, Value >::my_item
mutableprivate

Caches my_vector->internal_subscript(my_index)

NULL if cached value is not available

Definition at line 301 of file concurrent_vector.h.

◆ my_vector

template<typename Container, typename Value>
Container* tbb::internal::vector_iterator< Container, Value >::my_vector
private

concurrent_vector over which we are iterating.

Definition at line 294 of file concurrent_vector.h.

Referenced by tbb::internal::operator+(), and tbb::internal::operator==().


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.