Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Types | Static Private Member Functions | Private Attributes | List of all members
Ogre::SmallVector< T, N > Class Template Reference

SmallVector - This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small. More...

#include <OgreSmallVector.h>

Inheritance diagram for Ogre::SmallVector< T, N >:
Inheritance graph
[legend]

Public Types

typedef const T * const_iterator
 
typedef const T * const_pointer
 
typedef const T & const_reference
 
typedef std::reverse_iterator< const_iteratorconst_reverse_iterator
 
typedef ptrdiff_t difference_type
 
typedef SuperClass::iterator iterator
 
typedef T * pointer
 
typedef T & reference
 
typedef std::reverse_iterator< iteratorreverse_iterator
 
typedef SuperClass::size_type size_type
 
typedef T value_type
 

Public Member Functions

 SmallVector ()
 
 SmallVector (const SmallVector &RHS)
 
template<typename ItTy >
 SmallVector (ItTy S, ItTy E)
 
 SmallVector (unsigned Size, const T &Value=T())
 
template<typename in_iter >
void append (in_iter in_start, in_iter in_end)
 append - Add the specified range to the end of the SmallVector. More...
 
void append (size_type NumInputs, const T &Elt)
 append - Add the specified range to the end of the SmallVector. More...
 
void assign (unsigned NumElts, const T &Elt)
 
reference back ()
 
const_reference back () const
 
iterator begin ()
 
const_iterator begin () const
 
size_t capacity () const
 capacity - Return the total number of elements in the currently allocated buffer. More...
 
void clear ()
 
pointer data ()
 data - Return a pointer to the vector's buffer, even if empty(). More...
 
const_pointer data () const
 data - Return a pointer to the vector's buffer, even if empty(). More...
 
bool empty () const
 
iterator end ()
 
const_iterator end () const
 
iterator erase (iterator I)
 
iterator erase (iterator S, iterator E)
 
reference front ()
 
const_reference front () const
 
void grow (size_t MinSize=0)
 grow - double the size of the allocated memory, guaranteeing space for at least one more element or MinSize if specified. More...
 
iterator insert (iterator I, const T &Elt)
 
template<typename ItTy >
iterator insert (iterator I, ItTy From, ItTy To)
 
iterator insert (iterator I, size_type NumToInsert, const T &Elt)
 
size_type max_size () const
 
bool operator!= (const SmallVectorImpl &RHS) const
 
bool operator< (const SmallVectorImpl &RHS) const
 
const SmallVectoroperator= (const SmallVector &RHS)
 
bool operator== (const SmallVectorImpl &RHS) const
 
reference operator[] (unsigned idx)
 
const_reference operator[] (unsigned idx) const
 
void pop_back ()
 
pop_back_val ()
 
void push_back (const T &Elt)
 
reverse_iterator rbegin ()
 
const_reverse_iterator rbegin () const
 
reverse_iterator rend ()
 
const_reverse_iterator rend () const
 
void reserve (unsigned N)
 
void resize (unsigned N)
 
void resize (unsigned N, const T &NV)
 
void set_size (unsigned N)
 set_size - Set the array size to More...
 
size_type size () const
 
void swap (SmallVectorImpl &RHS)
 

Static Public Member Functions

static void destroy_range (T *S, T *E)
 
static void uninitialized_copy (It1 I, It1 E, It2 Dest)
 uninitialized_copy - Copy the range [I, E) onto the uninitialized memory starting with "Dest", constructing elements into it as needed. More...
 

Protected Member Functions

size_t capacity_in_bytes () const
 capacity_in_bytes - This returns capacity()*sizeof(T). More...
 
iterator capacity_ptr ()
 
const_iterator capacity_ptr () const
 
void grow_pod (size_t MinSizeInBytes, size_t TSize)
 grow_pod - This is an implementation of the grow() method which only works More...
 
bool isSmall () const
 isSmall - Return true if this is a smallvector which has not had dynamic memory allocated for it. More...
 
void setEnd (T *P)
 
size_t size_in_bytes () const
 size_in_bytes - This returns size()*sizeof(T). More...
 

Protected Attributes

void * BeginX
 
void * CapacityX
 
void * EndX
 
union Ogre::SmallVectorBase::U FirstEl
 

Private Types

enum  { MinUs }
 
typedef SmallVectorTemplateBase< T, isPodLike< T >::value > SuperClass
 
typedef SmallVectorImpl< T >::U U
 InlineElts - These are 'N-1' elements that are stored inline in the body of the vector. More...
 

Static Private Member Functions

static void construct_range (T *S, T *E, const T &Elt)
 

Private Attributes

U InlineElts [NumInlineEltsElts]
 

Detailed Description

template<typename T, unsigned N>
class Ogre::SmallVector< T, N >

SmallVector - This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.

It contains some number of elements in-place, which allows it to avoid heap allocation when the actual number of elements is below that threshold. This allows normal "small" cases to be fast without losing generality for large inputs.

Note that this does not attempt to be exception safe.

Definition at line 717 of file OgreSmallVector.h.

Member Typedef Documentation

◆ const_iterator

template<typename T >
typedef const T* Ogre::SmallVectorTemplateCommon< T >::const_iterator
inherited

Definition at line 173 of file OgreSmallVector.h.

◆ const_pointer

template<typename T >
typedef const T* Ogre::SmallVectorTemplateCommon< T >::const_pointer
inherited

Definition at line 181 of file OgreSmallVector.h.

◆ const_reference

template<typename T >
typedef const T& Ogre::SmallVectorTemplateCommon< T >::const_reference
inherited

Definition at line 179 of file OgreSmallVector.h.

◆ const_reverse_iterator

template<typename T >
typedef std::reverse_iterator<const_iterator> Ogre::SmallVectorTemplateCommon< T >::const_reverse_iterator
inherited

Definition at line 175 of file OgreSmallVector.h.

◆ difference_type

template<typename T >
typedef ptrdiff_t Ogre::SmallVectorTemplateCommon< T >::difference_type
inherited

Definition at line 170 of file OgreSmallVector.h.

◆ iterator

template<typename T >
typedef SuperClass::iterator Ogre::SmallVectorImpl< T >::iterator
inherited

Definition at line 332 of file OgreSmallVector.h.

◆ pointer

template<typename T >
typedef T* Ogre::SmallVectorTemplateCommon< T >::pointer
inherited

Definition at line 180 of file OgreSmallVector.h.

◆ reference

template<typename T >
typedef T& Ogre::SmallVectorTemplateCommon< T >::reference
inherited

Definition at line 178 of file OgreSmallVector.h.

◆ reverse_iterator

template<typename T >
typedef std::reverse_iterator<iterator> Ogre::SmallVectorTemplateCommon< T >::reverse_iterator
inherited

Definition at line 176 of file OgreSmallVector.h.

◆ size_type

template<typename T >
typedef SuperClass::size_type Ogre::SmallVectorImpl< T >::size_type
inherited

Definition at line 333 of file OgreSmallVector.h.

◆ SuperClass

template<typename T >
typedef SmallVectorTemplateBase<T, isPodLike<T>::value > Ogre::SmallVectorImpl< T >::SuperClass
privateinherited

Definition at line 328 of file OgreSmallVector.h.

◆ U

template<typename T , unsigned N>
typedef SmallVectorImpl<T>::U Ogre::SmallVector< T, N >::U
private

InlineElts - These are 'N-1' elements that are stored inline in the body of the vector.

The extra '1' element is stored in SmallVectorImpl.

Definition at line 720 of file OgreSmallVector.h.

◆ value_type

template<typename T >
typedef T Ogre::SmallVectorTemplateCommon< T >::value_type
inherited

Definition at line 171 of file OgreSmallVector.h.

Member Enumeration Documentation

◆ anonymous enum

template<typename T , unsigned N>
anonymous enum
private
Enumerator
MinUs 

Definition at line 721 of file OgreSmallVector.h.

Constructor & Destructor Documentation

◆ SmallVector() [1/4]

template<typename T , unsigned N>
Ogre::SmallVector< T, N >::SmallVector ( )

Definition at line 739 of file OgreSmallVector.h.

◆ SmallVector() [2/4]

template<typename T , unsigned N>
Ogre::SmallVector< T, N >::SmallVector ( unsigned  Size,
const T &  Value = T() 
)
explicit

◆ SmallVector() [3/4]

template<typename T , unsigned N>
template<typename ItTy >
Ogre::SmallVector< T, N >::SmallVector ( ItTy  S,
ItTy  E 
)

Definition at line 750 of file OgreSmallVector.h.

References Ogre::SmallVectorImpl< T >::append().

◆ SmallVector() [4/4]

template<typename T , unsigned N>
Ogre::SmallVector< T, N >::SmallVector ( const SmallVector< T, N > &  RHS)

Member Function Documentation

◆ append() [1/2]

template<typename T >
template<typename in_iter >
void Ogre::SmallVectorImpl< T >::append ( in_iter  in_start,
in_iter  in_end 
)
inherited

◆ append() [2/2]

template<typename T >
void Ogre::SmallVectorImpl< T >::append ( size_type  NumInputs,
const T &  Elt 
)
inherited

◆ assign()

template<typename T >
void Ogre::SmallVectorImpl< T >::assign ( unsigned  NumElts,
const T &  Elt 
)
inherited

◆ back() [1/2]

template<typename T >
reference Ogre::SmallVectorTemplateCommon< T >::back ( )
inherited

◆ back() [2/2]

template<typename T >
const_reference Ogre::SmallVectorTemplateCommon< T >::back ( ) const
inherited

Definition at line 230 of file OgreSmallVector.h.

References Ogre::SmallVectorTemplateCommon< T >::end().

◆ begin() [1/2]

template<typename T >
iterator Ogre::SmallVectorTemplateCommon< T >::begin ( )
inherited

◆ begin() [2/2]

template<typename T >
const_iterator Ogre::SmallVectorTemplateCommon< T >::begin ( ) const
inherited

Definition at line 185 of file OgreSmallVector.h.

References Ogre::SmallVectorBase::BeginX.

◆ capacity()

template<typename T >
size_t Ogre::SmallVectorTemplateCommon< T >::capacity ( ) const
inherited

◆ capacity_in_bytes()

size_t Ogre::SmallVectorBase::capacity_in_bytes ( ) const
protectedinherited

capacity_in_bytes - This returns capacity()*sizeof(T).

Definition at line 149 of file OgreSmallVector.h.

References Ogre::SmallVectorBase::BeginX, and Ogre::SmallVectorBase::CapacityX.

◆ capacity_ptr() [1/2]

template<typename T >
iterator Ogre::SmallVectorTemplateCommon< T >::capacity_ptr ( )
protectedinherited

◆ capacity_ptr() [2/2]

template<typename T >
const_iterator Ogre::SmallVectorTemplateCommon< T >::capacity_ptr ( ) const
protectedinherited

Definition at line 190 of file OgreSmallVector.h.

References Ogre::SmallVectorBase::CapacityX.

◆ clear()

template<typename T >
void Ogre::SmallVectorImpl< T >::clear ( void  )
inherited

◆ construct_range()

template<typename T >
static void Ogre::SmallVectorImpl< T >::construct_range ( T *  S,
T *  E,
const T &  Elt 
)
staticprivateinherited

◆ data() [1/2]

template<typename T >
pointer Ogre::SmallVectorTemplateCommon< T >::data ( )
inherited

data - Return a pointer to the vector's buffer, even if empty().

Definition at line 207 of file OgreSmallVector.h.

References Ogre::SmallVectorTemplateCommon< T >::begin().

◆ data() [2/2]

template<typename T >
const_pointer Ogre::SmallVectorTemplateCommon< T >::data ( ) const
inherited

data - Return a pointer to the vector's buffer, even if empty().

Definition at line 209 of file OgreSmallVector.h.

References Ogre::SmallVectorTemplateCommon< T >::begin().

◆ destroy_range()

static void Ogre::SmallVectorTemplateBase< T, isPodLike >::destroy_range ( T *  S,
T *  E 
)
staticinherited

Definition at line 242 of file OgreSmallVector.h.

◆ empty()

bool Ogre::SmallVectorBase::empty ( ) const
inherited

◆ end() [1/2]

template<typename T >
iterator Ogre::SmallVectorTemplateCommon< T >::end ( void  )
inherited

◆ end() [2/2]

template<typename T >
const_iterator Ogre::SmallVectorTemplateCommon< T >::end ( void  ) const
inherited

Definition at line 187 of file OgreSmallVector.h.

References Ogre::SmallVectorBase::EndX.

◆ erase() [1/2]

template<typename T >
iterator Ogre::SmallVectorImpl< T >::erase ( iterator  I)
inherited

◆ erase() [2/2]

template<typename T >
iterator Ogre::SmallVectorImpl< T >::erase ( iterator  S,
iterator  E 
)
inherited

◆ front() [1/2]

template<typename T >
reference Ogre::SmallVectorTemplateCommon< T >::front ( )
inherited

Definition at line 220 of file OgreSmallVector.h.

References Ogre::SmallVectorTemplateCommon< T >::begin().

◆ front() [2/2]

template<typename T >
const_reference Ogre::SmallVectorTemplateCommon< T >::front ( ) const
inherited

Definition at line 223 of file OgreSmallVector.h.

References Ogre::SmallVectorTemplateCommon< T >::begin().

◆ grow()

void Ogre::SmallVectorTemplateBase< T, isPodLike >::grow ( size_t  MinSize = 0)
inherited

grow - double the size of the allocated memory, guaranteeing space for at least one more element or MinSize if specified.

Definition at line 258 of file OgreSmallVector.h.

◆ grow_pod()

void Ogre::SmallVectorBase::grow_pod ( size_t  MinSizeInBytes,
size_t  TSize 
)
protectedinherited

grow_pod - This is an implementation of the grow() method which only works

on POD-like data types and is out of line to reduce code duplication.

Referenced by Ogre::SmallVectorTemplateBase< T, true >::grow().

◆ insert() [1/3]

template<typename T >
iterator Ogre::SmallVectorImpl< T >::insert ( iterator  I,
const T &  Elt 
)
inherited

◆ insert() [2/3]

template<typename T >
template<typename ItTy >
iterator Ogre::SmallVectorImpl< T >::insert ( iterator  I,
ItTy  From,
ItTy  To 
)
inherited

◆ insert() [3/3]

template<typename T >
iterator Ogre::SmallVectorImpl< T >::insert ( iterator  I,
size_type  NumToInsert,
const T &  Elt 
)
inherited

◆ isSmall()

bool Ogre::SmallVectorBase::isSmall ( ) const
protectedinherited

isSmall - Return true if this is a smallvector which has not had dynamic memory allocated for it.

Definition at line 139 of file OgreSmallVector.h.

References Ogre::SmallVectorBase::BeginX, and Ogre::SmallVectorBase::FirstEl.

Referenced by Ogre::SmallVectorImpl< T >::~SmallVectorImpl(), and Ogre::SmallVectorImpl< T >::swap().

◆ max_size()

template<typename T >
size_type Ogre::SmallVectorTemplateCommon< T >::max_size ( ) const
inherited

Definition at line 200 of file OgreSmallVector.h.

◆ operator!=()

template<typename T >
bool Ogre::SmallVectorImpl< T >::operator!= ( const SmallVectorImpl< T > &  RHS) const
inherited

Definition at line 590 of file OgreSmallVector.h.

◆ operator<()

template<typename T >
bool Ogre::SmallVectorImpl< T >::operator< ( const SmallVectorImpl< T > &  RHS) const
inherited

◆ operator=()

template<typename T , unsigned N>
const SmallVector & Ogre::SmallVector< T, N >::operator= ( const SmallVector< T, N > &  RHS)

Definition at line 759 of file OgreSmallVector.h.

References Ogre::SmallVectorImpl< T >::operator=().

◆ operator==()

template<typename T >
bool Ogre::SmallVectorImpl< T >::operator== ( const SmallVectorImpl< T > &  RHS) const
inherited

◆ operator[]() [1/2]

template<typename T >
reference Ogre::SmallVectorTemplateCommon< T >::operator[] ( unsigned  idx)
inherited

◆ operator[]() [2/2]

template<typename T >
const_reference Ogre::SmallVectorTemplateCommon< T >::operator[] ( unsigned  idx) const
inherited

◆ pop_back()

template<typename T >
void Ogre::SmallVectorImpl< T >::pop_back ( )
inherited

◆ pop_back_val()

template<typename T >
T Ogre::SmallVectorImpl< T >::pop_back_val ( )
inherited

◆ push_back()

template<typename T >
void Ogre::SmallVectorImpl< T >::push_back ( const T &  Elt)
inherited

◆ rbegin() [1/2]

template<typename T >
reverse_iterator Ogre::SmallVectorTemplateCommon< T >::rbegin ( )
inherited

Definition at line 194 of file OgreSmallVector.h.

References Ogre::SmallVectorTemplateCommon< T >::end().

◆ rbegin() [2/2]

template<typename T >
const_reverse_iterator Ogre::SmallVectorTemplateCommon< T >::rbegin ( ) const
inherited

Definition at line 195 of file OgreSmallVector.h.

References Ogre::SmallVectorTemplateCommon< T >::end().

◆ rend() [1/2]

template<typename T >
reverse_iterator Ogre::SmallVectorTemplateCommon< T >::rend ( )
inherited

Definition at line 196 of file OgreSmallVector.h.

References Ogre::SmallVectorTemplateCommon< T >::begin().

◆ rend() [2/2]

template<typename T >
const_reverse_iterator Ogre::SmallVectorTemplateCommon< T >::rend ( ) const
inherited

Definition at line 197 of file OgreSmallVector.h.

References Ogre::SmallVectorTemplateCommon< T >::begin().

◆ reserve()

template<typename T >
void Ogre::SmallVectorImpl< T >::reserve ( unsigned  N)
inherited

◆ resize() [1/2]

template<typename T >
void Ogre::SmallVectorImpl< T >::resize ( unsigned  N)
inherited

◆ resize() [2/2]

template<typename T >
void Ogre::SmallVectorImpl< T >::resize ( unsigned  N,
const T &  NV 
)
inherited

◆ set_size()

template<typename T >
void Ogre::SmallVectorImpl< T >::set_size ( unsigned  N)
inherited

set_size - Set the array size to

  • N, which the current array must have enough capacity for.

This does not construct or destroy any elements in the vector.

Clients can use this in conjunction with capacity() to write past the end of the buffer when they know that more elements are available, and only update the size later. This avoids the cost of value initializing elements which will only be overwritten.

Definition at line 608 of file OgreSmallVector.h.

References Ogre::SmallVectorTemplateCommon< T >::begin(), Ogre::SmallVectorTemplateCommon< T >::capacity(), and Ogre::SmallVectorTemplateCommon< T >::setEnd().

◆ setEnd()

template<typename T >
void Ogre::SmallVectorTemplateCommon< T >::setEnd ( T *  P)
protectedinherited

◆ size()

template<typename T >
size_type Ogre::SmallVectorTemplateCommon< T >::size ( void  ) const
inherited

◆ size_in_bytes()

size_t Ogre::SmallVectorBase::size_in_bytes ( ) const
protectedinherited

size_in_bytes - This returns size()*sizeof(T).

Definition at line 144 of file OgreSmallVector.h.

References Ogre::SmallVectorBase::BeginX, and Ogre::SmallVectorBase::EndX.

◆ swap()

template<typename T >
void Ogre::SmallVectorImpl< T >::swap ( SmallVectorImpl< T > &  RHS)
inherited

◆ uninitialized_copy()

static void Ogre::SmallVectorTemplateBase< T, isPodLike >::uninitialized_copy ( It1  I,
It1  E,
It2  Dest 
)
staticinherited

uninitialized_copy - Copy the range [I, E) onto the uninitialized memory starting with "Dest", constructing elements into it as needed.

Definition at line 252 of file OgreSmallVector.h.

Member Data Documentation

◆ BeginX

void* Ogre::SmallVectorBase::BeginX
protectedinherited

◆ CapacityX

void * Ogre::SmallVectorBase::CapacityX
protectedinherited

◆ EndX

void * Ogre::SmallVectorBase::EndX
protectedinherited

◆ FirstEl

union Ogre::SmallVectorBase::U Ogre::SmallVectorBase::FirstEl
protectedinherited

◆ InlineElts

template<typename T , unsigned N>
U Ogre::SmallVector< T, N >::InlineElts[NumInlineEltsElts]
private

Definition at line 737 of file OgreSmallVector.h.


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

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.