tbb::internal::fast_reverse_vector< T, max_segments > Class Template Reference

Vector that grows without reallocations, and stores items in the reverse order. More...

`#include <scheduler_utility.h>`

Collaboration diagram for tbb::internal::fast_reverse_vector< T, max_segments >:

## Public Member Functions

| fast_reverse_vector (T *initial_segment, size_t segment_size)
| ~fast_reverse_vector ()
size_t | size () const
void | push_back (const T &val)
void | copy_memory (T *dst) const
| Copies the contents of the vector into the dst array. More...

## Protected Attributes

T * | m_cur_segment
| The current (not completely filled) segment. More...
size_t | m_cur_segment_size
| Capacity of m_cur_segment. More...
size_t | m_pos
| Insertion position in m_cur_segment. More...
T * | m_segments [max_segments]
| Array of segments (has fixed size specified by the second template parameter) More...
size_t | m_num_segments
| Number of segments (the size of m_segments) More...
size_t | m_size
| Number of items in the segments in m_segments. More...

## Detailed Description

### template<typename T, size_t max_segments = 16>
class tbb::internal::fast_reverse_vector< T, max_segments >

Vector that grows without reallocations, and stores items in the reverse order.

Requires to initialize its first segment with a preallocated memory chunk (usually it is static array or an array allocated on the stack). The second template parameter specifies maximal number of segments. Each next segment is twice as large as the previous one.

Definition at line 56 of file scheduler_utility.h.

## Constructor & Destructor Documentation

## fast_reverse_vector()

template<typename T, size_t max_segments = 16>

tbb::internal::fast_reverse_vector< T, max_segments >::fast_reverse_vector | ( | T * | initial_segment,
|  | size_t | segment_size
| ) |  |

inline

Definition at line 59 of file scheduler_utility.h.

: m_cur_segment(initial_segment)
, m_cur_segment_size(segment_size)
, m_pos(segment_size)
, m_num_segments(0)
, m_size(0)
{
__TBB_ASSERT ( initial_segment && segment_size, "Nonempty initial segment must be supplied");
}

References __TBB_ASSERT.

## ~fast_reverse_vector()

template<typename T, size_t max_segments = 16>

tbb::internal::fast_reverse_vector< T, max_segments >::~fast_reverse_vector | ( |  | ) |

inline

Definition at line 69 of file scheduler_utility.h.

{
for ( size_t i = 1; i < m_num_segments; ++i )
NFS_Free( m_segments[i] );
}

References tbb::internal::fast_reverse_vector< T, max_segments >::m_num_segments, tbb::internal::fast_reverse_vector< T, max_segments >::m_segments, and tbb::internal::NFS_Free().

Here is the call graph for this function:

## Member Function Documentation

## copy_memory()

template<typename T, size_t max_segments = 16>

void tbb::internal::fast_reverse_vector< T, max_segments >::copy_memory | ( | T * | dst | ) | const

inline

Copies the contents of the vector into the dst array.

Can only be used when T is a POD type, as copying does not invoke copy constructors.

Definition at line 92 of file scheduler_utility.h.

{
size_t sz = m_cur_segment_size - m_pos;
memcpy( dst, m_cur_segment + m_pos, sz * sizeof(T) );
dst += sz;
sz = m_cur_segment_size / 2;
for ( long i = (long)m_num_segments - 2; i >= 0; --i ) {
memcpy( dst, m_segments[i], sz * sizeof(T) );
dst += sz;
sz /= 2;
}
}

References tbb::internal::fast_reverse_vector< T, max_segments >::m_cur_segment, tbb::internal::fast_reverse_vector< T, max_segments >::m_cur_segment_size, tbb::internal::fast_reverse_vector< T, max_segments >::m_num_segments, tbb::internal::fast_reverse_vector< T, max_segments >::m_pos, and tbb::internal::fast_reverse_vector< T, max_segments >::m_segments.

Referenced by tbb::internal::generic_scheduler::local_spawn().

Here is the caller graph for this function:

## push_back()

template<typename T, size_t max_segments = 16>

void tbb::internal::fast_reverse_vector< T, max_segments >::push_back | ( | const T & | val | ) |

inline

Definition at line 77 of file scheduler_utility.h.

{
if ( !m_pos ) {
if ( !m_num_segments ) m_segments[m_num_segments++] = m_cur_segment;
m_size += m_cur_segment_size;
m_cur_segment_size *= 2;
m_pos = m_cur_segment_size;
m_segments[m_num_segments++] = m_cur_segment = (T*)NFS_Allocate( m_cur_segment_size, sizeof(T), NULL );
__TBB_ASSERT ( m_num_segments < max_segments, "Maximal capacity exceeded" );
}
m_cur_segment[--m_pos] = val;
}

References __TBB_ASSERT, tbb::internal::fast_reverse_vector< T, max_segments >::m_cur_segment, tbb::internal::fast_reverse_vector< T, max_segments >::m_cur_segment_size, tbb::internal::fast_reverse_vector< T, max_segments >::m_num_segments, tbb::internal::fast_reverse_vector< T, max_segments >::m_pos, tbb::internal::fast_reverse_vector< T, max_segments >::m_segments, tbb::internal::fast_reverse_vector< T, max_segments >::m_size, and tbb::internal::NFS_Allocate().

Referenced by tbb::internal::generic_scheduler::local_spawn().

Here is the call graph for this function:
Here is the caller graph for this function:

## size()

template<typename T, size_t max_segments = 16>

size_t tbb::internal::fast_reverse_vector< T, max_segments >::size | ( |  | ) | const

inline

Definition at line 75 of file scheduler_utility.h.

{ return m_size + m_cur_segment_size - m_pos; }

References tbb::internal::fast_reverse_vector< T, max_segments >::m_cur_segment_size, tbb::internal::fast_reverse_vector< T, max_segments >::m_pos, and tbb::internal::fast_reverse_vector< T, max_segments >::m_size.

Referenced by tbb::internal::generic_scheduler::local_spawn().

Here is the caller graph for this function:

## Member Data Documentation

## m_cur_segment

template<typename T, size_t max_segments = 16>

T* tbb::internal::fast_reverse_vector< T, max_segments >::m_cur_segment

protected

The current (not completely filled) segment.

Definition at line 107 of file scheduler_utility.h.

Referenced by tbb::internal::fast_reverse_vector< T, max_segments >::copy_memory(), and tbb::internal::fast_reverse_vector< T, max_segments >::push_back().

## m_cur_segment_size

template<typename T, size_t max_segments = 16>

size_t tbb::internal::fast_reverse_vector< T, max_segments >::m_cur_segment_size

protected

Capacity of m_cur_segment.

Definition at line 110 of file scheduler_utility.h.

Referenced by tbb::internal::fast_reverse_vector< T, max_segments >::copy_memory(), tbb::internal::fast_reverse_vector< T, max_segments >::push_back(), and tbb::internal::fast_reverse_vector< T, max_segments >::size().

## m_num_segments

template<typename T, size_t max_segments = 16>

size_t tbb::internal::fast_reverse_vector< T, max_segments >::m_num_segments

protected

Number of segments (the size of m_segments)

Definition at line 119 of file scheduler_utility.h.

Referenced by tbb::internal::fast_reverse_vector< T, max_segments >::copy_memory(), tbb::internal::fast_reverse_vector< T, max_segments >::push_back(), and tbb::internal::fast_reverse_vector< T, max_segments >::~fast_reverse_vector().

## m_pos

template<typename T, size_t max_segments = 16>

size_t tbb::internal::fast_reverse_vector< T, max_segments >::m_pos

protected

Insertion position in m_cur_segment.

Definition at line 113 of file scheduler_utility.h.

Referenced by tbb::internal::fast_reverse_vector< T, max_segments >::copy_memory(), tbb::internal::fast_reverse_vector< T, max_segments >::push_back(), and tbb::internal::fast_reverse_vector< T, max_segments >::size().

## m_segments

template<typename T, size_t max_segments = 16>

T* tbb::internal::fast_reverse_vector< T, max_segments >::m_segments[max_segments]

protected

Array of segments (has fixed size specified by the second template parameter)

Definition at line 116 of file scheduler_utility.h.

Referenced by tbb::internal::fast_reverse_vector< T, max_segments >::copy_memory(), tbb::internal::fast_reverse_vector< T, max_segments >::push_back(), and tbb::internal::fast_reverse_vector< T, max_segments >::~fast_reverse_vector().

## m_size

template<typename T, size_t max_segments = 16>

size_t tbb::internal::fast_reverse_vector< T, max_segments >::m_size

protected

Number of items in the segments in m_segments.

Definition at line 122 of file scheduler_utility.h.

Referenced by tbb::internal::fast_reverse_vector< T, max_segments >::push_back(), and tbb::internal::fast_reverse_vector< T, max_segments >::size().

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

- scheduler_utility.h

tbb::internal::fast_reverse_vector::m_size
size_t m_size
Number of items in the segments in m_segments.
Definition: scheduler_utility.h:122
tbb::internal::fast_reverse_vector::m_cur_segment
T * m_cur_segment
The current (not completely filled) segment.
Definition: scheduler_utility.h:107
__TBB_ASSERT
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165
tbb::internal::fast_reverse_vector::m_num_segments
size_t m_num_segments
Number of segments (the size of m_segments)
Definition: scheduler_utility.h:119
tbb::internal::fast_reverse_vector::m_pos
size_t m_pos
Insertion position in m_cur_segment.
Definition: scheduler_utility.h:113
tbb::internal::fast_reverse_vector::m_cur_segment_size
size_t m_cur_segment_size
Capacity of m_cur_segment.
Definition: scheduler_utility.h:110
tbb::internal::NFS_Free
void __TBB_EXPORTED_FUNC NFS_Free(void *)
Free memory allocated by NFS_Allocate.
Definition: cache_aligned_allocator.cpp:198
tbb::internal::fast_reverse_vector::m_segments
T * m_segments[max_segments]
Array of segments (has fixed size specified by the second template parameter)
Definition: scheduler_utility.h:116
tbb::internal::NFS_Allocate
void *__TBB_EXPORTED_FUNC NFS_Allocate(size_t n_element, size_t element_size, void *hint)
Allocate memory on cache/sector line boundary.
Definition: cache_aligned_allocator.cpp:176

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.