alternative Standard Libary  0.29.8
std::fixed_vector< T, TCapacity, TGrowOnOverflow, TAllocator > Template-Klassenreferenz

#include <fixed_vector.hpp>

+ Klassendiagramm für std::fixed_vector< T, TCapacity, TGrowOnOverflow, TAllocator >:
+ Zusammengehörigkeiten von std::fixed_vector< T, TCapacity, TGrowOnOverflow, TAllocator >:

Öffentliche Typen

using iterator = T *
 
using const_iterator = const T *
 

Öffentliche Methoden

 fixed_vector (const allocator_type &allocator=allocator_type())
 
 fixed_vector (size_type initialSize, const allocator_type &allocator=allocator_type())
 
 fixed_vector (const T *first, const T *last, const allocator_type &allocator=allocator_type())
 
 fixed_vector (const fixed_vector &rhs, const allocator_type &allocator=allocator_type())
 
 fixed_vector (e_noinitialize n)
 
fixed_vectoroperator= (const fixed_vector &rhs)
 
void copy (const vector &rhs)
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
size_type size () const
 
bool empty () const
 
size_type capacity () const
 
T * data ()
 
const T * data () const
 
T & front ()
 
const T & front () const
 
T & back ()
 
const T & back () const
 
T & operator[] (size_type i)
 
const T & operator[] (size_type i) const
 
T & at (size_type i)
 
const T & at (size_type i) const
 
void push_back (const T &v)
 
void push_back ()
 
void pop_back ()
 
void assign (const T *first, const T *last)
 
void insert (size_type index, size_type n, const T &val)
 
void insert (iterator it, size_type n, const T &val)
 
iterator insert (iterator it, const T &val)
 
iterator erase (iterator it)
 
iterator erase (iterator first, iterator last)
 
void erase_unostdred (iterator it)
 
void resize (size_type n)
 
void reserve (size_type n)
 
void clear ()
 
void reset ()
 
void set_capacity (size_type newCapacity)
 
size_type index_of (const T &item, size_type index=0) const
 
iterator find (const T &item)
 
const allocator_type & get_allocator () const
 
void set_allocator (const allocator_type &allocator)
 
bool validate_iterator (const_iterator it) const
 
size_type get_high_watermark () const
 

Statische öffentliche Attribute

static const size_type kInitialCapacity
 
static const size_type npos = size_type(-1)
 

Ausführliche Beschreibung

template<typename T, int TCapacity, bool TGrowOnOverflow, class TAllocator = std::allocator>
class std::fixed_vector< T, TCapacity, TGrowOnOverflow, TAllocator >

Dokumentation der benutzerdefinierten Datentypen

◆ const_iterator

using std::vector< T, TAllocator, fixed_vector_storage< T, TAllocator, TCapacity, TGrowOnOverflow > >::const_iterator = const T*
inherited

◆ iterator

using std::vector< T, TAllocator, fixed_vector_storage< T, TAllocator, TCapacity, TGrowOnOverflow > >::iterator = T*
inherited

Beschreibung der Konstruktoren und Destruktoren

◆ fixed_vector() [1/5]

template<typename T , int TCapacity, bool TGrowOnOverflow, class TAllocator = std::allocator>
std::fixed_vector< T, TCapacity, TGrowOnOverflow, TAllocator >::fixed_vector ( const allocator_type &  allocator = allocator_type())
inlineexplicit
129  : base_vector(allocator)
130  {
131  }

◆ fixed_vector() [2/5]

template<typename T , int TCapacity, bool TGrowOnOverflow, class TAllocator = std::allocator>
std::fixed_vector< T, TCapacity, TGrowOnOverflow, TAllocator >::fixed_vector ( size_type  initialSize,
const allocator_type &  allocator = allocator_type() 
)
inlineexplicit
133  : base_vector(initialSize, allocator)
134  {
135  }

◆ fixed_vector() [3/5]

template<typename T , int TCapacity, bool TGrowOnOverflow, class TAllocator = std::allocator>
std::fixed_vector< T, TCapacity, TGrowOnOverflow, TAllocator >::fixed_vector ( const T *  first,
const T *  last,
const allocator_type &  allocator = allocator_type() 
)
inline
137  : base_vector(first, last, allocator)
138  {
139  }

◆ fixed_vector() [4/5]

template<typename T , int TCapacity, bool TGrowOnOverflow, class TAllocator = std::allocator>
std::fixed_vector< T, TCapacity, TGrowOnOverflow, TAllocator >::fixed_vector ( const fixed_vector< T, TCapacity, TGrowOnOverflow, TAllocator > &  rhs,
const allocator_type &  allocator = allocator_type() 
)
inline
141  : base_vector(rhs, allocator)
142  {
143  }

◆ fixed_vector() [5/5]

template<typename T , int TCapacity, bool TGrowOnOverflow, class TAllocator = std::allocator>
std::fixed_vector< T, TCapacity, TGrowOnOverflow, TAllocator >::fixed_vector ( e_noinitialize  n)
inlineexplicit
145  : base_vector(n)
146  {
147  }

Dokumentation der Elementfunktionen

◆ assign()

void std::vector< T, TAllocator, fixed_vector_storage< T, TAllocator, TCapacity, TGrowOnOverflow > >::assign ( const T *  first,
const T *  last 
)
inlineinherited
291  {
292  assert(!validate_iterator(first));
293  assert(!validate_iterator(last));
294 
295  const size_type count = size_type(last - first);
296  assert(count > 0);
297  clear();
298  if (m_begin + count > m_capacityEnd)
299  reallocate_discard_old(compute_new_capacity(count));
300 
301  std::copy_n(first, count, m_begin);
302  m_end = m_begin + count;
303  TStorage::record_high_watermark();
304  assert(invariant());
305  }
T * m_capacityEnd
Definition: fixed_vector.hpp:114
int size_type
Definition: vector.hpp:43
bool invariant() const
Definition: fixed_vector.hpp:95
void copy_n(const T *first, size_t n, T *result)
Definition: algorithm.hpp:35
T * m_begin
Definition: fixed_vector.hpp:111
void reallocate_discard_old(base_vector::size_type newCapacity)
Definition: fixed_vector.hpp:70
T * m_end
Definition: fixed_vector.hpp:112

◆ at() [1/2]

T& std::vector< T, TAllocator, fixed_vector_storage< T, TAllocator, TCapacity, TGrowOnOverflow > >::at ( size_type  i)
inlineinherited
251  {
252  assert(i < size());
253  return m_begin[i];
254  }
T * m_begin
Definition: fixed_vector.hpp:111

◆ at() [2/2]

const T& std::vector< T, TAllocator, fixed_vector_storage< T, TAllocator, TCapacity, TGrowOnOverflow > >::at ( size_type  i) const
inlineinherited
257  {
258  assert(i < size());
259  return m_begin[i];
260  }
T * m_begin
Definition: fixed_vector.hpp:111

◆ back() [1/2]

T& std::vector< T, TAllocator, fixed_vector_storage< T, TAllocator, TCapacity, TGrowOnOverflow > >::back ( )
inlineinherited
230  {
231  assert(!empty());
232  return *(end() - 1);
233  }

◆ back() [2/2]

const T& std::vector< T, TAllocator, fixed_vector_storage< T, TAllocator, TCapacity, TGrowOnOverflow > >::back ( ) const
inlineinherited
235  {
236  assert(!empty());
237  return *(end() - 1);
238  }

◆ begin() [1/2]

iterator std::vector< T, TAllocator, fixed_vector_storage< T, TAllocator, TCapacity, TGrowOnOverflow > >::begin ( )
inlineinherited
182  {
183  return m_begin;
184  }
T * m_begin
Definition: fixed_vector.hpp:111

◆ begin() [2/2]

const_iterator std::vector< T, TAllocator, fixed_vector_storage< T, TAllocator, TCapacity, TGrowOnOverflow > >::begin ( ) const
inlineinherited
186  {
187  return m_begin;
188  }
T * m_begin
Definition: fixed_vector.hpp:111

◆ capacity()

size_type std::vector< T, TAllocator, fixed_vector_storage< T, TAllocator, TCapacity, TGrowOnOverflow > >::capacity ( ) const
inlineinherited
206  {
207  return size_type(m_capacityEnd - m_begin);
208  }
T * m_capacityEnd
Definition: fixed_vector.hpp:114
int size_type
Definition: vector.hpp:43
T * m_begin
Definition: fixed_vector.hpp:111

◆ clear()

void std::vector< T, TAllocator, fixed_vector_storage< T, TAllocator, TCapacity, TGrowOnOverflow > >::clear ( )
inlineinherited
443  {
444  shrink(0);
445  assert(invariant());
446  }
bool invariant() const
Definition: fixed_vector.hpp:95

◆ copy()

void std::vector< T, TAllocator, fixed_vector_storage< T, TAllocator, TCapacity, TGrowOnOverflow > >::copy ( const vector< T, TAllocator, fixed_vector_storage< T, TAllocator, TCapacity, TGrowOnOverflow > > &  rhs)
inlineinherited
169  {
170  const size_type newSize = rhs.size();
171  if (newSize > capacity())
172  {
173  reallocate_discard_old(rhs.capacity());
174  }
175  std::copy_construct_n(rhs.m_begin, newSize, m_begin);
176  m_end = m_begin + newSize;
177  TStorage::record_high_watermark();
178  assert(invariant());
179  }
void copy_construct_n(T *first, size_t n, T *result)
Definition: algorithm.hpp:43
int size_type
Definition: vector.hpp:43
bool invariant() const
Definition: fixed_vector.hpp:95
T * m_begin
Definition: fixed_vector.hpp:111
void reallocate_discard_old(base_vector::size_type newCapacity)
Definition: fixed_vector.hpp:70
T * m_end
Definition: fixed_vector.hpp:112

◆ data() [1/2]

T* std::vector< T, TAllocator, fixed_vector_storage< T, TAllocator, TCapacity, TGrowOnOverflow > >::data ( )
inlineinherited
211  {
212  return empty() ? 0 : m_begin;
213  }
T * m_begin
Definition: fixed_vector.hpp:111

◆ data() [2/2]

const T* std::vector< T, TAllocator, fixed_vector_storage< T, TAllocator, TCapacity, TGrowOnOverflow > >::data ( ) const
inlineinherited
215  {
216  return empty() ? 0 : m_begin;
217  }
T * m_begin
Definition: fixed_vector.hpp:111

◆ empty()

bool std::vector< T, TAllocator, fixed_vector_storage< T, TAllocator, TCapacity, TGrowOnOverflow > >::empty ( ) const
inlineinherited
202  {
203  return m_begin == m_end;
204  }
T * m_begin
Definition: fixed_vector.hpp:111
T * m_end
Definition: fixed_vector.hpp:112

◆ end() [1/2]

iterator std::vector< T, TAllocator, fixed_vector_storage< T, TAllocator, TCapacity, TGrowOnOverflow > >::end ( )
inlineinherited
190  {
191  return m_end;
192  }
T * m_end
Definition: fixed_vector.hpp:112

◆ end() [2/2]

const_iterator std::vector< T, TAllocator, fixed_vector_storage< T, TAllocator, TCapacity, TGrowOnOverflow > >::end ( ) const
inlineinherited
194  {
195  return m_end;
196  }
T * m_end
Definition: fixed_vector.hpp:112

◆ erase() [1/2]

iterator std::vector< T, TAllocator, fixed_vector_storage< T, TAllocator, TCapacity, TGrowOnOverflow > >::erase ( iterator  it)
inlineinherited
387  {
388  assert(validate_iterator(it));
389  assert(it != end());
390  assert(invariant());
391 
392  // Move everything down, overwriting *it
393  if (it + 1 < m_end)
394  {
395  move_down_1(it, int_to_type<has_trivial_copy<T>::value>());
396  }
397  --m_end;
399  return it;
400  }
void destruct(T *mem)
Definition: algorithm.hpp:31
bool invariant() const
Definition: fixed_vector.hpp:95
T * m_end
Definition: fixed_vector.hpp:112

◆ erase() [2/2]

iterator std::vector< T, TAllocator, fixed_vector_storage< T, TAllocator, TCapacity, TGrowOnOverflow > >::erase ( iterator  first,
iterator  last 
)
inlineinherited
402  {
403  assert(validate_iterator(first));
404  assert(validate_iterator(last));
405  assert(invariant());
406  if (last <= first)
407  return end();
408 
409  const size_type indexFirst = size_type(first - m_begin);
410  const size_type toRemove = size_type(last - first);
411  if (toRemove > 0)
412  {
413  move_down(last, first, int_to_type<has_trivial_copy<T>::value>());
414  shrink(size() - toRemove);
415  }
416  return m_begin + indexFirst;
417  }
int size_type
Definition: vector.hpp:43
bool invariant() const
Definition: fixed_vector.hpp:95
T * m_begin
Definition: fixed_vector.hpp:111

◆ erase_unostdred()

void std::vector< T, TAllocator, fixed_vector_storage< T, TAllocator, TCapacity, TGrowOnOverflow > >::erase_unostdred ( iterator  it)
inlineinherited
420  {
421  assert(validate_iterator(it));
422  assert(it != end());
423  assert(invariant());
424  const iterator itNewEnd = end() - 1;
425  if (it != itNewEnd)
426  *it = *itNewEnd;
427  pop_back();
428  }
bool invariant() const
Definition: fixed_vector.hpp:95

◆ find()

iterator std::vector< T, TAllocator, fixed_vector_storage< T, TAllocator, TCapacity, TGrowOnOverflow > >::find ( const T &  item)
inlineinherited
467  {
468  iterator itEnd = end();
469  for (iterator it = begin(); it != itEnd; ++it)
470  if (*it == item)
471  return it;
472  return itEnd;
473  }

◆ front() [1/2]

T& std::vector< T, TAllocator, fixed_vector_storage< T, TAllocator, TCapacity, TGrowOnOverflow > >::front ( )
inlineinherited

◆ front() [2/2]

const T& std::vector< T, TAllocator, fixed_vector_storage< T, TAllocator, TCapacity, TGrowOnOverflow > >::front ( ) const
inlineinherited

◆ get_allocator()

const allocator_type& std::vector< T, TAllocator, fixed_vector_storage< T, TAllocator, TCapacity, TGrowOnOverflow > >::get_allocator ( ) const
inlineinherited
476  {
477  return m_allocator;
478  }
TAllocator m_allocator
Definition: fixed_vector.hpp:115

◆ get_high_watermark()

size_type std::vector< T, TAllocator, fixed_vector_storage< T, TAllocator, TCapacity, TGrowOnOverflow > >::get_high_watermark ( ) const
inlineinherited
489  {
490  return TStorage::get_high_watermark();
491  }

◆ index_of()

size_type std::vector< T, TAllocator, fixed_vector_storage< T, TAllocator, TCapacity, TGrowOnOverflow > >::index_of ( const T &  item,
size_type  index = 0 
) const
inlineinherited
459  {
460  assert(index >= 0 && index < size());
461  for ( ; index < size(); ++index)
462  if (m_begin[index] == item)
463  return index;
464  return npos;
465  }
static const size_type npos
Definition: vector.hpp:44
T * m_begin
Definition: fixed_vector.hpp:111

◆ insert() [1/3]

void std::vector< T, TAllocator, fixed_vector_storage< T, TAllocator, TCapacity, TGrowOnOverflow > >::insert ( size_type  index,
size_type  n,
const T &  val 
)
inlineinherited
308  {
309  assert(invariant());
310  const size_type indexEnd = index + n;
311  const size_type prevSize = size();
312  if (m_end + n > m_capacityEnd)
313  {
314  reallocate(compute_new_capacity(prevSize + n), prevSize);
315  }
316  if (indexEnd > prevSize)
317  {
318  const size_type numCopy = prevSize - index;
319  const size_type numAppend = indexEnd - prevSize;
320  assert(numCopy >= 0 && numAppend >= 0);
321  assert(numAppend + numCopy == n);
322  iterator itOut = m_begin + prevSize;
323  for (size_type i = 0; i < numAppend; ++i, ++itOut)
324  std::copy_construct(itOut, val);
325  std::copy_construct_n(m_begin + index, numCopy, itOut);
326  for (size_type i = 0; i < numCopy; ++i)
327  m_begin[index + i] = val;
328  }
329  else
330  {
332  iterator insertPos = m_begin + index;
333  std::move_n(insertPos, prevSize - indexEnd, insertPos + n);
334  for (size_type i = 0; i < n; ++i)
335  insertPos[i] = val;
336  }
337  m_end += n;
338  TStorage::record_high_watermark();
339  }
void copy_construct_n(T *first, size_t n, T *result)
Definition: algorithm.hpp:43
void copy_construct(T *mem, const T &orig)
Definition: algorithm.hpp:23
void reallocate(base_vector::size_type newCapacity, base_vector::size_type oldSize)
Definition: fixed_vector.hpp:50
T * m_capacityEnd
Definition: fixed_vector.hpp:114
int size_type
Definition: vector.hpp:43
bool invariant() const
Definition: fixed_vector.hpp:95
void move_n(const T *from, size_t n, T *result)
Definition: algorithm.hpp:47
T * m_begin
Definition: fixed_vector.hpp:111
T * m_end
Definition: fixed_vector.hpp:112

◆ insert() [2/3]

void std::vector< T, TAllocator, fixed_vector_storage< T, TAllocator, TCapacity, TGrowOnOverflow > >::insert ( iterator  it,
size_type  n,
const T &  val 
)
inlineinherited
342  {
343  assert(validate_iterator(it));
344  assert(invariant());
345  insert(size_type(it - m_begin), n, val);
346  }
void insert(size_type index, size_type n, const T &val)
Definition: vector.hpp:307
int size_type
Definition: vector.hpp:43
bool invariant() const
Definition: fixed_vector.hpp:95
T * m_begin
Definition: fixed_vector.hpp:111

◆ insert() [3/3]

iterator std::vector< T, TAllocator, fixed_vector_storage< T, TAllocator, TCapacity, TGrowOnOverflow > >::insert ( iterator  it,
const T &  val 
)
inlineinherited
348  {
349  assert(validate_iterator(it));
350  assert(invariant());
351 
352  const size_type index = (size_type)(it - m_begin);
353  if (m_end == m_capacityEnd)
354  {
355  grow();
356  it = m_begin + index;
357  }
358  else
359  {
361  }
362 
363  if (m_end > it)
364  {
365  if(!has_trivial_copy<T>::value)
366  {
367  const size_type prevSize = size();
368  assert(index <= prevSize);
369  const size_type toMove = prevSize - index;
370 
371  std::internal::move_n(it, toMove, it + 1, int_to_type<has_trivial_copy<T>::value>());
372  }
373  else
374  {
375  assert(it < m_end);
376  const size_t n = reinterpret_cast<uintptr_t>(m_end) - reinterpret_cast<uintptr_t>(it);
377  Sys::MemMove(it + 1, it, n);
378  }
379  }
380  *it = val;
381  ++m_end;
382  assert(invariant());
383  TStorage::record_high_watermark();
384  return it;
385  }
void construct(T *mem)
Definition: algorithm.hpp:27
T * m_capacityEnd
Definition: fixed_vector.hpp:114
int size_type
Definition: vector.hpp:43
bool invariant() const
Definition: fixed_vector.hpp:95
T * m_begin
Definition: fixed_vector.hpp:111
T * m_end
Definition: fixed_vector.hpp:112
void move_n(const T *from, size_t n, T *result, int_to_type< false >)
Definition: utility.hpp:92

◆ operator=()

template<typename T , int TCapacity, bool TGrowOnOverflow, class TAllocator = std::allocator>
fixed_vector& std::fixed_vector< T, TCapacity, TGrowOnOverflow, TAllocator >::operator= ( const fixed_vector< T, TCapacity, TGrowOnOverflow, TAllocator > &  rhs)
inline
150  {
151  if (&rhs != this)
152  {
153  base_vector::copy(rhs);
154  }
155  return *this;
156  }

◆ operator[]() [1/2]

T& std::vector< T, TAllocator, fixed_vector_storage< T, TAllocator, TCapacity, TGrowOnOverflow > >::operator[] ( size_type  i)
inlineinherited
241  {
242  return at(i);
243  }

◆ operator[]() [2/2]

const T& std::vector< T, TAllocator, fixed_vector_storage< T, TAllocator, TCapacity, TGrowOnOverflow > >::operator[] ( size_type  i) const
inlineinherited
246  {
247  return at(i);
248  }

◆ pop_back()

void std::vector< T, TAllocator, fixed_vector_storage< T, TAllocator, TCapacity, TGrowOnOverflow > >::pop_back ( )
inlineinherited
284  {
285  assert(!empty());
286  --m_end;
288  }
void destruct(T *mem)
Definition: algorithm.hpp:31
T * m_end
Definition: fixed_vector.hpp:112

◆ push_back() [1/2]

void std::vector< T, TAllocator, fixed_vector_storage< T, TAllocator, TCapacity, TGrowOnOverflow > >::push_back ( const T &  v)
inlineinherited
263  {
264  if (m_end < m_capacityEnd)
265  {
267  }
268  else
269  {
270  grow();
272  }
273  TStorage::record_high_watermark();
274  }
void copy_construct(T *mem, const T &orig)
Definition: algorithm.hpp:23
T * m_capacityEnd
Definition: fixed_vector.hpp:114
T * m_end
Definition: fixed_vector.hpp:112

◆ push_back() [2/2]

void std::vector< T, TAllocator, fixed_vector_storage< T, TAllocator, TCapacity, TGrowOnOverflow > >::push_back ( )
inlineinherited
276  {
277  if (m_end == m_capacityEnd)
278  grow();
280  ++m_end;
281  TStorage::record_high_watermark();
282  }
void construct(T *mem)
Definition: algorithm.hpp:27
T * m_capacityEnd
Definition: fixed_vector.hpp:114
T * m_end
Definition: fixed_vector.hpp:112

◆ reserve()

void std::vector< T, TAllocator, fixed_vector_storage< T, TAllocator, TCapacity, TGrowOnOverflow > >::reserve ( size_type  n)
inlineinherited
438  {
439  if (n > capacity())
440  reallocate(n, size());
441  }
void reallocate(base_vector::size_type newCapacity, base_vector::size_type oldSize)
Definition: fixed_vector.hpp:50

◆ reset()

void std::vector< T, TAllocator, fixed_vector_storage< T, TAllocator, TCapacity, TGrowOnOverflow > >::reset ( )
inlineinherited
449  {
450  TStorage::reset();
451  assert(invariant());
452  }
bool invariant() const
Definition: fixed_vector.hpp:95

◆ resize()

void std::vector< T, TAllocator, fixed_vector_storage< T, TAllocator, TCapacity, TGrowOnOverflow > >::resize ( size_type  n)
inlineinherited
431  {
432  if (n > size())
433  insert(m_end, n - size(), value_type());
434  else
435  shrink(n);
436  }
void insert(size_type index, size_type n, const T &val)
Definition: vector.hpp:307
T * m_end
Definition: fixed_vector.hpp:112

◆ set_allocator()

void std::vector< T, TAllocator, fixed_vector_storage< T, TAllocator, TCapacity, TGrowOnOverflow > >::set_allocator ( const allocator_type allocator)
inlineinherited
480  {
481  m_allocator = allocator;
482  }
TAllocator m_allocator
Definition: fixed_vector.hpp:115

◆ set_capacity()

void std::vector< T, TAllocator, fixed_vector_storage< T, TAllocator, TCapacity, TGrowOnOverflow > >::set_capacity ( size_type  newCapacity)
inlineinherited
454  {
455  reallocate(newCapacity, size());
456  }
void reallocate(base_vector::size_type newCapacity, base_vector::size_type oldSize)
Definition: fixed_vector.hpp:50

◆ size()

size_type std::vector< T, TAllocator, fixed_vector_storage< T, TAllocator, TCapacity, TGrowOnOverflow > >::size ( ) const
inlineinherited
198  {
199  return size_type(m_end - m_begin);
200  }
int size_type
Definition: vector.hpp:43
T * m_begin
Definition: fixed_vector.hpp:111
T * m_end
Definition: fixed_vector.hpp:112

◆ validate_iterator()

bool std::vector< T, TAllocator, fixed_vector_storage< T, TAllocator, TCapacity, TGrowOnOverflow > >::validate_iterator ( const_iterator  it) const
inlineinherited

Dokumentation der Datenelemente

◆ kInitialCapacity

const size_type std::vector< T, TAllocator, fixed_vector_storage< T, TAllocator, TCapacity, TGrowOnOverflow > >::kInitialCapacity
staticinherited

◆ npos

const size_type std::base_vector::npos = size_type(-1)
staticinherited

Die Dokumentation für diese Klasse wurde erzeugt aufgrund der Datei: