OGRE  2.3
Object-Oriented Graphics Rendering Engine
Ogre::FastArray< T > Class Template Reference

Lightweight implementation of std::vector. More...

#include <OgreFastArray.h>

Public Types

typedef const T * const_iterator
 
typedef T * iterator
 
typedef T value_type
 

Public Member Functions

 FastArray ()
 
 FastArray (const FastArray< T > &copy)
 
 FastArray (size_t count, const T &value)
 Creates an array pushing the value N times. More...
 
 FastArray (size_t reserveAmount)
 Creates an array reserving the amount of elements (memory is not initialized) More...
 
 ~FastArray ()
 
void append (const_iterator otherBegin, const_iterator otherEnd)
 
void appendPOD (const_iterator otherBegin, const_iterator otherEnd)
 
T & back ()
 
const T & back () const
 
iterator begin ()
 
const_iterator begin () const
 
size_t capacity () const
 
void clear ()
 
void destroy ()
 
bool empty () const
 
iterator end ()
 
const_iterator end () const
 
iterator erase (iterator first, iterator last)
 
iterator erase (iterator toErase)
 
iterator erasePOD (iterator first, iterator last)
 
T & front ()
 
const T & front () const
 
iterator insert (iterator where, const T &val)
 
iterator insertPOD (iterator where, const_iterator otherBegin, const_iterator otherEnd)
 otherBegin & otherEnd must not overlap with this->begin() and this->end() More...
 
void operator= (const FastArray< T > &copy)
 
T & operator[] (size_t idx)
 
const T & operator[] (size_t idx) const
 
void pop_back ()
 
void push_back (const T &val)
 
void reserve (size_t reserveAmount)
 
void resize (size_t newSize, const T &value=T())
 
void resizePOD (size_t newSize, const T &value=T())
 
size_t size () const
 
void swap (FastArray< T > &other)
 

Detailed Description

template<typename T>
class Ogre::FastArray< T >

Lightweight implementation of std::vector.

Remarks
The problem with std::vector is that some implementations (eg. Visual Studio's) have a lot of range checking and debugging code that slows them down a lot. MSVC's security features can be disabled defining the macro "#define _SECURE_SCL 0". However that must be done as a global macro, and turns out we don't want to disable those nice warnings and out-of-bounds checkings in a lot of sections of our code (except may be for extremely optimized Release builds)
Since we can't enable/disable those checkings selectively, I wrote our own lightweight container for performance-sensitive areas where we're also very certain we won't use them incorrectly.
It's partially STL compliant, for example std::for_each works with it. However some functions are not, for example FastArray<int> myArray(5) does not behave as the standard does: FastArray will reserve 5 ints, while std::vector will push 5 ints and default-initialize them (in the case of ints, fill it with 5 zeros)
Only use this container for extremely performance sensitive and you're certain you'll be using it correctly. If you're in doubt or don't know what to do, use std::vector instead.
FastArray was created because we needed to keep multiple lists (one per thread) of culled MovableObjects pointers (against the camera) and then iterate through all of them. These multiple levels of indirection was causing MS implementation to go mad with a huge amount of useless bounds checking & iterator validation.
Author
Matias N. Goldberg
Version
1.0

Member Typedef Documentation

◆ const_iterator

template<typename T >
typedef const T* Ogre::FastArray< T >::const_iterator

◆ iterator

template<typename T >
typedef T* Ogre::FastArray< T >::iterator

◆ value_type

template<typename T >
typedef T Ogre::FastArray< T >::value_type

Constructor & Destructor Documentation

◆ FastArray() [1/4]

template<typename T >
Ogre::FastArray< T >::FastArray ( )
inline

◆ FastArray() [2/4]

template<typename T >
Ogre::FastArray< T >::FastArray ( const FastArray< T > &  copy)
inline

◆ FastArray() [3/4]

template<typename T >
Ogre::FastArray< T >::FastArray ( size_t  reserveAmount)
inline

Creates an array reserving the amount of elements (memory is not initialized)

◆ FastArray() [4/4]

template<typename T >
Ogre::FastArray< T >::FastArray ( size_t  count,
const T &  value 
)
inline

Creates an array pushing the value N times.

◆ ~FastArray()

template<typename T >
Ogre::FastArray< T >::~FastArray ( )
inline

Member Function Documentation

◆ append()

template<typename T >
void Ogre::FastArray< T >::append ( const_iterator  otherBegin,
const_iterator  otherEnd 
)
inline

◆ appendPOD()

template<typename T >
void Ogre::FastArray< T >::appendPOD ( const_iterator  otherBegin,
const_iterator  otherEnd 
)
inline

◆ back() [1/2]

template<typename T >
T& Ogre::FastArray< T >::back ( )
inline

◆ back() [2/2]

template<typename T >
const T& Ogre::FastArray< T >::back ( ) const
inline

◆ begin() [1/2]

template<typename T >
iterator Ogre::FastArray< T >::begin ( )
inline

Referenced by Ogre::bitset64::clear().

◆ begin() [2/2]

template<typename T >
const_iterator Ogre::FastArray< T >::begin ( ) const
inline

◆ capacity()

template<typename T >
size_t Ogre::FastArray< T >::capacity ( ) const
inline

◆ clear()

template<typename T >
void Ogre::FastArray< T >::clear ( void  )
inline

◆ destroy()

template<typename T >
void Ogre::FastArray< T >::destroy ( void  )
inline

◆ empty()

template<typename T >
bool Ogre::FastArray< T >::empty ( void  ) const
inline

◆ end() [1/2]

◆ end() [2/2]

template<typename T >
const_iterator Ogre::FastArray< T >::end ( ) const
inline

◆ erase() [1/2]

template<typename T >
iterator Ogre::FastArray< T >::erase ( iterator  first,
iterator  last 
)
inline

◆ erase() [2/2]

template<typename T >
iterator Ogre::FastArray< T >::erase ( iterator  toErase)
inline

◆ erasePOD()

template<typename T >
iterator Ogre::FastArray< T >::erasePOD ( iterator  first,
iterator  last 
)
inline

◆ front() [1/2]

template<typename T >
T& Ogre::FastArray< T >::front ( )
inline

◆ front() [2/2]

template<typename T >
const T& Ogre::FastArray< T >::front ( ) const
inline

◆ insert()

template<typename T >
iterator Ogre::FastArray< T >::insert ( iterator  where,
const T &  val 
)
inline

◆ insertPOD()

template<typename T >
iterator Ogre::FastArray< T >::insertPOD ( iterator  where,
const_iterator  otherBegin,
const_iterator  otherEnd 
)
inline

otherBegin & otherEnd must not overlap with this->begin() and this->end()

◆ operator=()

template<typename T >
void Ogre::FastArray< T >::operator= ( const FastArray< T > &  copy)
inline

◆ operator[]() [1/2]

template<typename T >
T& Ogre::FastArray< T >::operator[] ( size_t  idx)
inline

◆ operator[]() [2/2]

template<typename T >
const T& Ogre::FastArray< T >::operator[] ( size_t  idx) const
inline

◆ pop_back()

template<typename T >
void Ogre::FastArray< T >::pop_back ( )
inline

◆ push_back()

template<typename T >
void Ogre::FastArray< T >::push_back ( const T &  val)
inline

◆ reserve()

template<typename T >
void Ogre::FastArray< T >::reserve ( size_t  reserveAmount)
inline

◆ resize()

template<typename T >
void Ogre::FastArray< T >::resize ( size_t  newSize,
const T &  value = T() 
)
inline

◆ resizePOD()

template<typename T >
void Ogre::FastArray< T >::resizePOD ( size_t  newSize,
const T &  value = T() 
)
inline

Referenced by Ogre::bitset64::reset().

◆ size()

◆ swap()

template<typename T >
void Ogre::FastArray< T >::swap ( FastArray< T > &  other)
inline

References std::swap().


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