tbb::internal::vector_iterator< Container, Value > Class Template Reference
Containers

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= (const vector_iterator< Container, typename Container::value_type > &other)
vector_iterator | operator+ (ptrdiff_t offset) const
vector_iterator & | operator+= (ptrdiff_t offset)
vector_iterator | operator- (ptrdiff_t offset) const
vector_iterator & | operator-= (ptrdiff_t offset)
Value & | operator* () const
Value & | operator[] (ptrdiff_t k) const
Value * | operator-> () const
vector_iterator & | operator++ ()
| Pre increment. More...
vector_iterator & | operator-- ()
| 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 70 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 429 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 433 of file concurrent_vector.h.

## pointer

template<typename Container, typename Value>

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

Definition at line 431 of file concurrent_vector.h.

## reference

template<typename Container, typename Value>

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

Definition at line 432 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 430 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`
| ) |  |

inline private

Definition at line 328 of file concurrent_vector.h.

:
my_vector(const_cast<Container*>(&vector)),
my_index(index),
my_item(static_cast<Value*>(ptr))
{}

## vector_iterator() [2/3]

template<typename Container, typename Value>

tbb::internal::vector_iterator< Container, Value >::vector_iterator | ( |  | ) |

inline

Default constructor.

Definition at line 336 of file concurrent_vector.h.

: my_vector(NULL), my_index(~size_t(0)), my_item(NULL) {}

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

:
my_vector(other.my_vector),
my_index(other.my_index),
my_item(other.my_item)
{}

## Member Function Documentation

## 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.

{
Value* item = my_item;
if( !item ) {
item = my_item = &my_vector->internal_subscript(my_index);
}
__TBB_ASSERT( item==&my_vector->internal_subscript(my_index), "corrupt cache" );
return *item;
}

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

{
return vector_iterator( *my_vector, my_index+offset );
}

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

{
size_t element_index = ++my_index;
if( my_item ) {
//TODO: consider using of knowledge about "first_block optimization" here as well?
if( concurrent_vector_base::is_first_element_in_segment(element_index)) {
//if the iterator crosses a segment boundary, the pointer become invalid
//as possibly next segment is in another memory location
my_item= NULL;
} else {
++my_item;
}
}
return *this;
}

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

{
vector_iterator result = *this;
operator++();
return result;
}

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

{
my_index+=offset;
my_item = NULL;
return *this;
}

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

{
return vector_iterator( *my_vector, my_index-offset );
}

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

{
__TBB_ASSERT( my_index>0, "operator--() applied to iterator already at beginning of concurrent_vector" );
size_t element_index = my_index--;
if( my_item ) {
if(concurrent_vector_base::is_first_element_in_segment(element_index)) {
//if the iterator crosses a segment boundary, the pointer become invalid
//as possibly next segment is in another memory location
my_item= NULL;
} else {
--my_item;
}
}
return *this;
}

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

{
vector_iterator result = *this;
operator--();
return result;
}

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

{
my_index-=offset;
my_item = NULL;
return *this;
}

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

{return &operator*();}

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= | ( | const vector_iterator< Container, typename Container::value_type > & | other | ) |

inline

Definition at line 344 of file concurrent_vector.h.

{
my_vector=other.my_vector;
my_index=other.my_index;
my_item=other.my_item;
return *this;
}

References 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.

## operator[]()

template<typename Container, typename Value>

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

inline

Definition at line 376 of file concurrent_vector.h.

{
return my_vector->internal_subscript(my_index+k);
}

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 319 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 323 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

Index into the vector.

Definition at line 300 of file concurrent_vector.h.

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

## my_item

template<typename Container, typename Value>

Value* tbb::internal::vector_iterator< Container, Value >::my_item

mutable private

Caches my_vector->internal_subscript(my_index)

NULL if cached value is not available

Definition at line 304 of file concurrent_vector.h.

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

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

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

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

- concurrent_vector.h

tbb::internal::vector_iterator::my_item
Value * my_item
Caches my_vector->internal_subscript(my_index)
Definition: concurrent_vector.h:304
__TBB_ASSERT
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165
tbb::internal::vector_iterator::operator*
Value & operator*() const
Definition: concurrent_vector.h:368
tbb::internal::vector_iterator::vector_iterator
vector_iterator()
Default constructor.
Definition: concurrent_vector.h:336
tbb::internal::vector_iterator::operator++
vector_iterator & operator++()
Pre increment.
Definition: concurrent_vector.h:382
tbb::internal::vector_iterator::my_index
size_t my_index
Index into the vector.
Definition: concurrent_vector.h:300
tbb::internal::vector_iterator::my_vector
Container * my_vector
concurrent_vector over which we are iterating.
Definition: concurrent_vector.h:297
tbb::internal::vector_iterator::operator--
vector_iterator & operator--()
Pre decrement.
Definition: concurrent_vector.h:398
tbb::internal::concurrent_vector_base_v3::is_first_element_in_segment
static bool is_first_element_in_segment(size_type element_index)
Definition: concurrent_vector.h:233

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