SLProject 4.0.000
SLVector< T, U > Class Template Reference

Template class for dynamic vector. More...

#include <SLVector.h>

Public Member Functions

 SLVector ()
 creates empty array More...
 
 SLVector (SLuint size)
 creates array w. size More...
 
 SLVector (const SLVector &a)
 creates a copy of array a More...
 
virtual ~SLVector ()
 standard destructor More...
 
SLVector< T, U > & operator= (const SLVector &a)
 assignment operator More...
 
SLVector< T, U > & operator= (const SLVector *a)
 assignment operator More...
 
T & operator[] (SLuint i)
 access operator More...
 
void set (const SLVector &a)
 set array with another More...
 
size ()
 returns size More...
 
capacity ()
 returns internal size More...
 
void push_back (const T element)
 appends element at end More...
 
void pop_back ()
 deletes element at end More...
 
void erase (U i)
 delete element at pos i More...
 
T & at (SLuint i)
 returns element at pos i More...
 
void reverse ()
 reverses the order More...
 
void clear ()
 deletes all More...
 
void resize (SLuint64 size=0)
 deletes all, sets _size=size More...
 
void reserve (SLuint64 newSize)
 set capacity = newSize More...
 

Private Attributes

_size
 real size of array of type U More...
 
_capacity
 internal size of array of type U More...
 
T * _contents
 pointer to the array of type T More...
 

Detailed Description

template<class T, class U>
class SLVector< T, U >

Template class for dynamic vector.

Implements a minimal dynamic sized array like the STL vector. The array can be of a class type T and can have the max. size of type U. Compatibility is given as long no iterators are used. Bounds checks are only done in _DEBUG mode within the access methods and operators.

Constructor & Destructor Documentation

◆ SLVector() [1/3]

template<class T , class U >
SLVector< T, U >::SLVector

creates empty array

◆ SLVector() [2/3]

template<class T , class U >
SLVector< T, U >::SLVector ( SLuint  size)

creates array w. size

◆ SLVector() [3/3]

template<class T , class U >
SLVector< T, U >::SLVector ( const SLVector< T, U > &  a)

creates a copy of array a

◆ ~SLVector()

template<class T , class U >
SLVector< T, U >::~SLVector
virtual

standard destructor

Member Function Documentation

◆ at()

template<class T , class U >
T & SLVector< T, U >::at ( SLuint  i)
inline

returns element at pos i

Returns the element at position i. Overrun is checked in _DEBUG mode and causes Warning but returns a value so that the caller can be reached.

◆ capacity()

template<class T , class U >
U SLVector< T, U >::capacity ( )
inline

returns internal size

◆ clear()

template<class T , class U >
void SLVector< T, U >::clear ( )
inline

deletes all

◆ erase()

template<class T , class U >
void SLVector< T, U >::erase ( i)

delete element at pos i

◆ operator=() [1/2]

template<class T , class U >
SLVector< T, U > & SLVector< T, U >::operator= ( const SLVector< T, U > &  a)

assignment operator

◆ operator=() [2/2]

template<class T , class U >
SLVector< T, U > & SLVector< T, U >::operator= ( const SLVector< T, U > *  a)

assignment operator

◆ operator[]()

template<class T , class U >
T & SLVector< T, U >::operator[] ( SLuint  i)
inline

access operator

The bracket operator as used in arrays. You can use it on the left or right side of =. Overrun is checked in _DEBUG mode and causes Warning but returns a value so that the caller can be reached.

◆ pop_back()

template<class T , class U >
void SLVector< T, U >::pop_back

deletes element at end

◆ push_back()

template<class T , class U >
void SLVector< T, U >::push_back ( const T  element)

appends element at end

◆ reserve()

template<class T , class U >
void SLVector< T, U >::reserve ( SLuint64  newSize)

set capacity = newSize

Internal, the SLVector is representet by an c++Array not of size _size, but of an internal size. The function reserve changes the internal representation and can make adding much more faster. If s is smaller than the actual size, it will be ignored.

◆ resize()

template<class T , class U >
void SLVector< T, U >::resize ( SLuint64  size = 0)

deletes all, sets _size=size

◆ reverse()

template<class T , class U >
void SLVector< T, U >::reverse

reverses the order

◆ set()

template<class T , class U >
void SLVector< T, U >::set ( const SLVector< T, U > &  a)

set array with another

◆ size()

template<class T , class U >
U SLVector< T, U >::size ( )
inline

returns size

Member Data Documentation

◆ _capacity

template<class T , class U >
U SLVector< T, U >::_capacity
private

internal size of array of type U

◆ _contents

template<class T , class U >
T* SLVector< T, U >::_contents
private

pointer to the array of type T

◆ _size

template<class T , class U >
U SLVector< T, U >::_size
private

real size of array of type U


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