The Pedigree Project 0.1
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
Vector< T > Class Template Reference

A vector / dynamic array. More...

#include <Vector.h>

+ Inheritance diagram for Vector< T >:
+ Collaboration diagram for Vector< T >:

Classes

struct  ReverseIteratorContainer
 

Public Types

typedef T * Iterator
 
typedef T const * ConstIterator
 
typedef ReverseIteratorContainer< T * > ReverseIterator
 
typedef ReverseIteratorContainer< const T * > ConstReverseIterator
 

Public Member Functions

 Vector ()
 
 Vector (size_t size)
 
 Vector (const Vector &x)
 
 ~Vector ()
 
Vector & operator= (const Vector &x)
 
T & operator[] (size_t index)
 
const T & operator[] (size_t index) const
 
size_t size () const
 
size_t count () const
 
void pushBack (const T &value)
 
template<class... Args>
void createBack (Args &&... args)
 
void pushBack (T &&value)
 
T popBack ()
 
void pushFront (const T &value)
 
void pushFront (T &&value)
 
T popFront ()
 
void setAt (size_t idx, const T &value)
 
void swap (Iterator a, Iterator b)
 
void swap (Vector &other) noexcept
 
void insert (size_t index, const T &value)
 
void clear (bool freeMem=false)
 
void erase (size_t index)
 
Iterator erase (Iterator iter)
 
ReverseIterator erase (ReverseIterator iter)
 
Iterator begin ()
 
ConstIterator begin () const
 
Iterator end ()
 
ConstIterator end () const
 
ReverseIterator rbegin ()
 
ConstReverseIterator rbegin () const
 
ReverseIterator rend ()
 
ConstReverseIterator rend () const
 
void assign (const Vector &x)
 
void reserve (size_t size, bool copy)
 
bool tryReserve (size_t size, bool copy=true)
 

Private Member Functions

void reserve (size_t size, bool copy, bool free)
 

Private Attributes

size_t m_Size
 
size_t m_Count
 
size_t m_Start
 
T * m_Data
 

Static Private Attributes

static const int m_ReserveFactor = 2
 

Detailed Description

template<class T>
class Vector< T >

A vector / dynamic array.

General Vector template class, aka dynamic array

Definition at line 33 of file Vector.h.

Member Typedef Documentation

◆ ConstIterator

template<class T >
typedef T const* Vector< T >::ConstIterator

Contant random-access iterator for the Vector

Definition at line 38 of file Vector.h.

◆ ConstReverseIterator

template<class T >
typedef ReverseIteratorContainer<const T*> Vector< T >::ConstReverseIterator

Definition at line 77 of file Vector.h.

◆ Iterator

template<class T >
typedef T* Vector< T >::Iterator

Random-access iterator for the Vector

Definition at line 36 of file Vector.h.

◆ ReverseIterator

template<class T >
typedef ReverseIteratorContainer<T*> Vector< T >::ReverseIterator

Definition at line 76 of file Vector.h.

Member Function Documentation

◆ begin() [1/2]

template<class T >
Iterator Vector< T >::begin ( )
inline

◆ begin() [2/2]

template<class T >
ConstIterator Vector< T >::begin ( ) const
inline

Get a constant iterator pointing to the beginning of the Vector

Returns
constant iterator pointing to the beginning of the Vector

Definition at line 167 of file Vector.h.

◆ createBack()

template<class T >
template<class... Args>
void Vector< T >::createBack ( Args &&...  args)
inline

Create an element in place at the end of the Vector

Definition at line 110 of file Vector.h.

◆ end() [1/2]

template<class T >
Iterator Vector< T >::end ( )
inline

◆ end() [2/2]

template<class T >
ConstIterator Vector< T >::end ( ) const
inline

Get a constant iterator pointing to the last element + 1

Returns
constant iterator pointing to the last element + 1

Definition at line 177 of file Vector.h.

◆ rbegin() [1/2]

template<class T >
ReverseIterator Vector< T >::rbegin ( )
inline

Definition at line 181 of file Vector.h.

◆ rbegin() [2/2]

template<class T >
ConstReverseIterator Vector< T >::rbegin ( ) const
inline

Definition at line 184 of file Vector.h.

◆ rend() [1/2]

template<class T >
ReverseIterator Vector< T >::rend ( )
inline

Definition at line 187 of file Vector.h.

◆ rend() [2/2]

template<class T >
ConstReverseIterator Vector< T >::rend ( ) const
inline

Definition at line 190 of file Vector.h.

◆ swap()

template<class T >
void Vector< T >::swap ( Vector< T > &  other)
noexcept

Exchange storage without constructing, allocating or destroying elements.

Definition at line 531 of file Vector.h.

Member Data Documentation

◆ m_Count

template<class T >
size_t Vector< T >::m_Count
private

The number of elements in the Vector

Definition at line 211 of file Vector.h.

◆ m_Data

template<class T >
T* Vector< T >::m_Data
private

Pointer to the Elements

Definition at line 218 of file Vector.h.

◆ m_ReserveFactor

template<class T >
const int Vector< T >::m_ReserveFactor = 2
staticprivate

Factor to multiply by in reserve().

Definition at line 220 of file Vector.h.

◆ m_Size

template<class T >
size_t Vector< T >::m_Size
private

The number of elements we have reserved space for

Definition at line 209 of file Vector.h.

◆ m_Start

template<class T >
size_t Vector< T >::m_Start
private

The current start index in the array. This is used to reduce the need to keep copying the array contents.

Definition at line 216 of file Vector.h.


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