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 71 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 422 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 426 of file concurrent_vector.h.

◆ pointer

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

Definition at line 424 of file concurrent_vector.h.

◆ reference

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

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

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

◆ vector_iterator() [2/3]

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

Default constructor.

Definition at line 337 of file concurrent_vector.h.

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

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

339  :
340  my_vector(other.my_vector),
341  my_index(other.my_index),
342  my_item(other.my_item)
343  {}
size_t my_index
Index into the vector.
Container * my_vector
concurrent_vector over which we are iterating.
Value * my_item
Caches my_vector->internal_subscript(my_index)

Member Function Documentation

◆ operator*()

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

Definition at line 361 of file concurrent_vector.h.

361  {
362  Value* item = my_item;
363  if( !item ) {
364  item = my_item = &my_vector->internal_subscript(my_index);
365  }
366  __TBB_ASSERT( item==&my_vector->internal_subscript(my_index), "corrupt cache" );
367  return *item;
368  }
size_t my_index
Index into the vector.
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)

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

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

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

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

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

407  {
408  vector_iterator result = *this;
409  operator++();
410  return result;
411  }
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 348 of file concurrent_vector.h.

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

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

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

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

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

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

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

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

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

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

372 {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 369 of file concurrent_vector.h.

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

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 320 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 324 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-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.