Graphite  Version 3
An experimental 3D geometry processing program
GEO::vector< T > Class Template Reference

Vector with aligned memory allocation. More...

#include <geogram/basic/memory.h>

Inheritance diagram for GEO::vector< T >:

Public Member Functions

 vector ()
 Creates an empty vector.
 
 vector (index_t size)
 Creates a pre-allocated vector. More...
 
 vector (index_t size, const T &val)
 Creates a pre-initialized vector. More...
 
index_t size () const
 Gets the number of elements. More...
 
T & operator[] (index_t i)
 Gets a vector element. More...
 
const T & operator[] (index_t i) const
 Gets a vector element. More...
 
T & operator[] (signed_index_t i)
 Gets a vector element. More...
 
const T & operator[] (signed_index_t i) const
 Gets a vector element. More...
 
T * data ()
 Gets a pointer to the array of elements. More...
 
const T * data () const
 Gets a pointer to the array of elements. More...
 

Detailed Description

template<class T>
class GEO::vector< T >

Vector with aligned memory allocation.

Class vector is a std::vector that uses a memory-aligned allocator Memory-aligned allocation makes it well suited for SSE/AVX/... vector code generation.

See also
Memory::aligned_allocator

Definition at line 635 of file memory.h.

Constructor & Destructor Documentation

◆ vector() [1/2]

template<class T >
GEO::vector< T >::vector ( index_t  size)
inlineexplicit

Creates a pre-allocated vector.

Constructs a container with size elements. Each element is default-constructed.

Parameters
[in]sizeNumber of elements to allocate

Definition at line 655 of file memory.h.

◆ vector() [2/2]

template<class T >
GEO::vector< T >::vector ( index_t  size,
const T &  val 
)
inlineexplicit

Creates a pre-initialized vector.

Constructs a container with size elements. Each element is a copy of val.

Parameters
[in]sizeNumber of elements to allocate
[in]valInitial value of the elements

Definition at line 666 of file memory.h.

Member Function Documentation

◆ data() [1/2]

template<class T >
T* GEO::vector< T >::data ( )
inline

Gets a pointer to the array of elements.

Returns
a pointer to the first element of the vector

Definition at line 774 of file memory.h.

◆ data() [2/2]

template<class T >
const T* GEO::vector< T >::data ( ) const
inline

Gets a pointer to the array of elements.

Returns
a const pointer to the first element of the vector

Definition at line 782 of file memory.h.

◆ operator[]() [1/4]

template<class T >
T& GEO::vector< T >::operator[] ( index_t  i)
inline

Gets a vector element.

Parameters
[in]iindex of the element
Returns
A reference to the element at position i in the vector.

Definition at line 687 of file memory.h.

◆ operator[]() [2/4]

template<class T >
const T& GEO::vector< T >::operator[] ( index_t  i) const
inline

Gets a vector element.

Parameters
[in]iindex of the element
Returns
A const reference to the element at position i in the vector.

Definition at line 698 of file memory.h.

◆ operator[]() [3/4]

template<class T >
T& GEO::vector< T >::operator[] ( signed_index_t  i)
inline

Gets a vector element.

Parameters
[in]iindex of the element
Returns
A reference to the element at position i in the vector.

Definition at line 708 of file memory.h.

◆ operator[]() [4/4]

template<class T >
const T& GEO::vector< T >::operator[] ( signed_index_t  i) const
inline

Gets a vector element.

Parameters
[in]iindex of the element
Returns
A const reference to the element at position i in the vector.

Definition at line 719 of file memory.h.

◆ size()

template<class T >
index_t GEO::vector< T >::size ( ) const
inline

Gets the number of elements.

Returns
The actual number of elements in the vector

Definition at line 674 of file memory.h.


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