Whole Vector Operations

Caution

Concurrent invocation of these operations on the same instance is not safe.

The following table provides additional information on the members of this template class.
Member Description
void reserve( size_type n )

Reserves space for at least n elements.

Throws std::length_error if n>max_size(). It can also throw an exception if the allocator throws an exception.

Safety: If an exception is thrown, the instance remains in a valid state.

void shrink_to_fit()

Compacts the internal representation to reduce fragmentation.

Note

Method shrink_to_fit was called compact() in Intel® Threading Building Blocks (Intel® TBB) 2.1. It was renamed to match the C++11 std::vector::shrink_to_fit().

void swap( concurrent_vector& x )

Swap contents of two vectors. Takes O(1) time.

void clear()

Erases all elements. Afterwards, size()==0. Does not free internal arrays.

Tip

To free internal arrays, call shrink_to_fit() after clear().

Note

The original release of Intel® TBB 2.1 and its "update 1" freed the arrays. The change in "update 2" reverts back to the behavior of Intel® TBB 2.0. The motivation for not freeing the arrays is to behave similarly to std::vector::clear().

~concurrent_vector()

Erases all elements and destroys the vector.