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 69 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 420 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 424 of file concurrent_vector.h.

◆ pointer

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

Definition at line 422 of file concurrent_vector.h.

◆ reference

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

Definition at line 423 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 421 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 327 of file concurrent_vector.h.

327  :
328  my_vector(const_cast<Container*>(&vector)),
329  my_index(index),
330  my_item(static_cast<Value*>(ptr))
331  {}
Container * my_vector
concurrent_vector over which we are iterating.
Value * my_item
Caches my_vector->internal_subscript(my_index)
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 335 of file concurrent_vector.h.

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

Referenced by tbb::internal::vector_iterator< Container, Value >::operator+(), and tbb::internal::vector_iterator< Container, Value >::operator-().

Here is the caller graph for this function:

◆ 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 337 of file concurrent_vector.h.

337  :
338  my_vector(other.my_vector),
339  my_index(other.my_index),
340  my_item(other.my_item)
341  {}
Container * my_vector
concurrent_vector over which we are iterating.
Value * my_item
Caches my_vector->internal_subscript(my_index)
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 359 of file concurrent_vector.h.

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

References __TBB_ASSERT, tbb::internal::vector_iterator< Container, Value >::my_index, tbb::internal::vector_iterator< Container, Value >::my_item, and tbb::internal::vector_iterator< Container, Value >::my_vector.

Referenced by tbb::internal::vector_iterator< Container, Value >::operator->().

Here is the caller graph for this function:

◆ operator+()

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

Definition at line 343 of file concurrent_vector.h.

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

References tbb::internal::vector_iterator< Container, Value >::my_index, tbb::internal::vector_iterator< Container, Value >::my_vector, and tbb::internal::vector_iterator< Container, Value >::vector_iterator().

Here is the call graph for this function:

◆ operator++() [1/2]

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

Pre increment.

Definition at line 373 of file concurrent_vector.h.

373  {
374  size_t element_index = ++my_index;
375  if( my_item ) {
376  //TODO: consider using of knowledge about "first_block optimization" here as well?
378  //if the iterator crosses a segment boundary, the pointer become invalid
379  //as possibly next segment is in another memory location
380  my_item= NULL;
381  } else {
382  ++my_item;
383  }
384  }
385  return *this;
386  }
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.

References tbb::internal::concurrent_vector_base_v3::is_first_element_in_segment(), tbb::internal::vector_iterator< Container, Value >::my_index, and tbb::internal::vector_iterator< Container, Value >::my_item.

Referenced by tbb::internal::vector_iterator< Container, Value >::operator++().

Here is the call graph for this function:
Here is the caller 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 405 of file concurrent_vector.h.

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

References tbb::internal::vector_iterator< Container, Value >::operator++().

Here is the call graph for this function:

◆ operator+=()

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

Definition at line 346 of file concurrent_vector.h.

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

References tbb::internal::vector_iterator< Container, Value >::my_index, and tbb::internal::vector_iterator< Container, Value >::my_item.

◆ operator-()

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

Definition at line 351 of file concurrent_vector.h.

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

References tbb::internal::vector_iterator< Container, Value >::my_index, tbb::internal::vector_iterator< Container, Value >::my_vector, and tbb::internal::vector_iterator< Container, Value >::vector_iterator().

Here is the call graph for this function:

◆ operator--() [1/2]

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

Pre decrement.

Definition at line 389 of file concurrent_vector.h.

389  {
390  __TBB_ASSERT( my_index>0, "operator--() applied to iterator already at beginning of concurrent_vector" );
391  size_t element_index = my_index--;
392  if( my_item ) {
394  //if the iterator crosses a segment boundary, the pointer become invalid
395  //as possibly next segment is in another memory location
396  my_item= NULL;
397  } else {
398  --my_item;
399  }
400  }
401  return *this;
402  }
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:169
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.

References __TBB_ASSERT, tbb::internal::concurrent_vector_base_v3::is_first_element_in_segment(), tbb::internal::vector_iterator< Container, Value >::my_index, and tbb::internal::vector_iterator< Container, Value >::my_item.

Referenced by tbb::internal::vector_iterator< Container, Value >::operator--().

Here is the call graph for this function:
Here is the caller 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 412 of file concurrent_vector.h.

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

References tbb::internal::vector_iterator< Container, Value >::operator--().

Here is the call graph for this function:

◆ operator-=()

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

Definition at line 354 of file concurrent_vector.h.

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

References tbb::internal::vector_iterator< Container, Value >::my_index, and tbb::internal::vector_iterator< Container, Value >::my_item.

◆ operator->()

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

Definition at line 370 of file concurrent_vector.h.

370 {return &operator*();}

References tbb::internal::vector_iterator< Container, Value >::operator *().

Here is the call graph for this function:

◆ operator[]()

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

Definition at line 367 of file concurrent_vector.h.

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

References tbb::internal::vector_iterator< Container, Value >::my_index, and tbb::internal::vector_iterator< Container, Value >::my_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 318 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 322 of file concurrent_vector.h.

Member Data Documentation

◆ my_index

◆ my_item

◆ my_vector


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

Copyright © 2005-2018 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.