Geogram Version 1.8.5
A programming library of geometric algorithms
Loading...
Searching...
No Matches
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.
 
 vector (index_t size, const T &val)
 Creates a pre-initialized vector.
 
index_t size () const
 Gets the number of elements.
 
T & operator[] (index_t i)
 Gets a vector element.
 
const T & operator[] (index_t i) const
 Gets a vector element.
 
T & operator[] (signed_index_t i)
 Gets a vector element.
 
const T & operator[] (signed_index_t i) const
 Gets a vector element.
 
T * data ()
 Gets a pointer to the array of elements.
 
const T * data () const
 Gets a pointer to the array of elements.
 

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 623 of file memory.h.

Constructor & Destructor Documentation

◆ vector() [1/3]

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

Creates an empty vector.

Definition at line 633 of file memory.h.

◆ vector() [2/3]

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 643 of file memory.h.

◆ vector() [3/3]

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 654 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 762 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 770 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 675 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 686 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 696 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 707 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 662 of file memory.h.


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