Mitsuba Renderer  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mitsuba::BlockedVector< T, BlockSize > Class Template Reference

Basic vector implementation, which stores all data in a list of fixed-sized blocks. More...

#include <mitsuba/render/gkdtree.h>

Public Member Functions

 BlockedVector ()
 
 ~BlockedVector ()
 
void push_back (const T &value)
 Append an element to the end. More...
 
T *__restrict allocate (size_t size)
 Allocate a certain number of elements and return a pointer to the first one. More...
 
T & operator[] (size_t index)
 
const T & operator[] (size_t index) const
 
size_t size () const
 Return the currently used number of items. More...
 
size_t blockCount () const
 Return the number of allocated blocks. More...
 
size_t capacity () const
 Return the total capacity. More...
 
void resize (size_t pos)
 Resize the vector to the given size. More...
 
void clear ()
 Release all memory. More...
 

Detailed Description

template<typename T, size_t BlockSize>
class mitsuba::BlockedVector< T, BlockSize >

Basic vector implementation, which stores all data in a list of fixed-sized blocks.

This leads to a more conservative memory usage when the final size of a (possibly very large) growing vector is unknown. Also, frequent reallocations & copies are avoided.

Author
Wenzel Jakob

Constructor & Destructor Documentation

template<typename T, size_t BlockSize>
mitsuba::BlockedVector< T, BlockSize >::BlockedVector ( )
inline
template<typename T, size_t BlockSize>
mitsuba::BlockedVector< T, BlockSize >::~BlockedVector ( )
inline

Member Function Documentation

template<typename T, size_t BlockSize>
T* __restrict mitsuba::BlockedVector< T, BlockSize >::allocate ( size_t  size)
inline

Allocate a certain number of elements and return a pointer to the first one.

The implementation will ensure that they lie contiguous in memory – note that this can potentially create unused elements in the previous block if a new one has to be allocated.

template<typename T, size_t BlockSize>
size_t mitsuba::BlockedVector< T, BlockSize >::blockCount ( ) const
inline

Return the number of allocated blocks.

template<typename T, size_t BlockSize>
size_t mitsuba::BlockedVector< T, BlockSize >::capacity ( ) const
inline

Return the total capacity.

template<typename T, size_t BlockSize>
void mitsuba::BlockedVector< T, BlockSize >::clear ( )
inline

Release all memory.

template<typename T, size_t BlockSize>
T& mitsuba::BlockedVector< T, BlockSize >::operator[] ( size_t  index)
inline
template<typename T, size_t BlockSize>
const T& mitsuba::BlockedVector< T, BlockSize >::operator[] ( size_t  index) const
inline
template<typename T, size_t BlockSize>
void mitsuba::BlockedVector< T, BlockSize >::push_back ( const T &  value)
inline

Append an element to the end.

template<typename T, size_t BlockSize>
void mitsuba::BlockedVector< T, BlockSize >::resize ( size_t  pos)
inline

Resize the vector to the given size.

Note: this implementation doesn't support enlarging the vector and simply changes the last item pointer.

template<typename T, size_t BlockSize>
size_t mitsuba::BlockedVector< T, BlockSize >::size ( ) const
inline

Return the currently used number of items.


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