Nori

BlockedVector< T, BlockSize > Class Template Reference

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

#include <gkdtree.h>

List of all members.

Public Member Functions

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

Detailed Description

template<typename T, size_t BlockSize>
class 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

Definition at line 230 of file gkdtree.h.


Constructor & Destructor Documentation

template<typename T, size_t BlockSize>
BlockedVector< T, BlockSize >::BlockedVector ( ) [inline]

Definition at line 232 of file gkdtree.h.

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

Definition at line 234 of file gkdtree.h.


Member Function Documentation

template<typename T, size_t BlockSize>
T* 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.

Definition at line 259 of file gkdtree.h.

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

Return the number of allocated blocks.

Definition at line 299 of file gkdtree.h.

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

Return the total capacity.

Definition at line 306 of file gkdtree.h.

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

Release all memory.

Definition at line 324 of file gkdtree.h.

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

Definition at line 283 of file gkdtree.h.

template<typename T, size_t BlockSize>
T& BlockedVector< T, BlockSize >::operator[] ( size_t  index) [inline]

Definition at line 278 of file gkdtree.h.

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

Append an element to the end.

Definition at line 241 of file gkdtree.h.

template<typename T, size_t BlockSize>
void 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.

Definition at line 317 of file gkdtree.h.

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

Return the currently used number of items.

Definition at line 292 of file gkdtree.h.


The documentation for this class was generated from the following file:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines