SOFA API  1a4bb3e7
Open source framework for multi-physics simuation
sofa::type::vector< T, MemoryManager > Class Template Reference

#include <vector_T.h>

Inheritance diagram for sofa::type::vector< T, MemoryManager >:

Detailed Description

template<class T, class MemoryManager = CPUMemoryManager<T>>
class sofa::type::vector< T, MemoryManager >

Regular vector Using CPUMemoryManager, it has the same behavior as std::vector with extra conveniences:

  • string serialization (making it usable in Data)
  • operator[] is checking if the index is within the bounds in debug

Public Member Functions

 vector ()
 Basic constructor. More...
 
 vector (Size n, const T &value)
 Constructor. More...
 
 vector (Size n)
 Constructor. More...
 
 vector (const std::vector< T, Alloc > &x)
 Constructor. More...
 
 vector (const std::initializer_list< T > &t)
 Brace initalizer constructor. More...
 
 vector (std::vector< T, Alloc > &&v)
 Move constructor. More...
 
vectoroperator= (const std::vector< T, Alloc > &x)
 Copy operator. More...
 
vectoroperator= (std::vector< T, Alloc > &&v)
 Move assignment operator. More...
 
 vector (typename vector< T >::const_iterator first, typename vector< T >::const_iterator last)
 Constructor. More...
 
reference operator[] (Size n)
 Read/write random access. More...
 
const_reference operator[] (Size n) const
 Read-only random access. More...
 
std::ostream & write (std::ostream &os) const
 
std::istream & read (std::istream &in)
 
void fill (const T &value)
 Sets every element to 'value'. More...
 
void fastResize (Size n)
 
SOFA_TYPE_API std::istream & read (std::istream &in)
 
SOFA_TYPE_API std::istream & read (std::istream &in)
 
SOFA_TYPE_API std::ostream & write (std::ostream &os) const
 
SOFA_TYPE_API std::istream & read (std::istream &in)
 
SOFA_TYPE_API std::istream & read (std::istream &in)
 Specialization for reading vectors of int and unsigned int using "A-B" notation for all integers between A and B. More...
 
SOFA_TYPE_API std::istream & read (std::istream &in)
 
SOFA_TYPE_API std::ostream & write (std::ostream &os) const
 Specialization for writing vectors of unsigned char. More...
 
SOFA_TYPE_API std::istream & read (std::istream &in)
 
SOFA_TYPE_API std::ostream & write (std::ostream &os) const
 
SOFA_TYPE_API std::ostream & write (std::ostream &os) const
 

Friends

std::ostream & operator<< (std::ostream &os, const vector &vec)
 Output stream. More...
 
std::istream & operator>> (std::istream &in, vector &vec)
 Input stream. More...
 

Constructor details

◆ vector() [1/7]

template<class T , class MemoryManager = CPUMemoryManager<T>>
sofa::type::vector< T, MemoryManager >::vector ( )
inline

Basic constructor.

◆ vector() [2/7]

template<class T , class MemoryManager = CPUMemoryManager<T>>
sofa::type::vector< T, MemoryManager >::vector ( Size  n,
const T &  value 
)
inline

Constructor.

◆ vector() [3/7]

template<class T , class MemoryManager = CPUMemoryManager<T>>
sofa::type::vector< T, MemoryManager >::vector ( Size  n)
inlineexplicit

Constructor.

◆ vector() [4/7]

template<class T , class MemoryManager = CPUMemoryManager<T>>
sofa::type::vector< T, MemoryManager >::vector ( const std::vector< T, Alloc > &  x)
inline

Constructor.

◆ vector() [5/7]

template<class T , class MemoryManager = CPUMemoryManager<T>>
sofa::type::vector< T, MemoryManager >::vector ( const std::initializer_list< T > &  t)
inline

Brace initalizer constructor.

◆ vector() [6/7]

template<class T , class MemoryManager = CPUMemoryManager<T>>
sofa::type::vector< T, MemoryManager >::vector ( std::vector< T, Alloc > &&  v)
inline

Move constructor.

◆ vector() [7/7]

template<class T , class MemoryManager = CPUMemoryManager<T>>
sofa::type::vector< T, MemoryManager >::vector ( typename vector< T >::const_iterator  first,
typename vector< T >::const_iterator  last 
)
inline

Constructor.

Function details

◆ fastResize()

template<class T , class MemoryManager = CPUMemoryManager<T>>
void sofa::type::vector< T, MemoryManager >::fastResize ( Size  n)
inline

this function is usefull for vector_device because it resize the vector without device operation (if device is not valid). Therefore the function is used in asynchronous code to safly resize a vector which is either cuda of type::vector

◆ fill()

template<class T , class MemoryManager = CPUMemoryManager<T>>
void sofa::type::vector< T, MemoryManager >::fill ( const T &  value)
inline

Sets every element to 'value'.

◆ operator=() [1/2]

template<class T , class MemoryManager = CPUMemoryManager<T>>
vector& sofa::type::vector< T, MemoryManager >::operator= ( const std::vector< T, Alloc > &  x)
inline

Copy operator.

◆ operator=() [2/2]

template<class T , class MemoryManager = CPUMemoryManager<T>>
vector& sofa::type::vector< T, MemoryManager >::operator= ( std::vector< T, Alloc > &&  v)
inline

Move assignment operator.

◆ operator[]() [1/2]

template<class T , class MemoryManager = CPUMemoryManager<T>>
reference sofa::type::vector< T, MemoryManager >::operator[] ( Size  n)
inline

Read/write random access.

◆ operator[]() [2/2]

template<class T , class MemoryManager = CPUMemoryManager<T>>
const_reference sofa::type::vector< T, MemoryManager >::operator[] ( Size  n) const
inline

Read-only random access.

◆ read() [1/7]

SOFA_TYPE_API std::istream & sofa::type::vector< int >::read ( std::istream &  in)

Input stream Specialization for reading vectors of int and unsigned int using "A-B" notation for all integers between A and B, optionnally specifying a step using "A-B-step" notation.

◆ read() [2/7]

SOFA_TYPE_API std::istream & sofa::type::vector< unsigned int >::read ( std::istream &  in)

Input stream Specialization for reading vectors of int and unsigned int using "A-B" notation for all integers between A and B

◆ read() [3/7]

SOFA_TYPE_API std::istream & sofa::type::vector< unsigned char >::read ( std::istream &  in)

Input stream Specialization for reading vectors of unsigned char

◆ read() [4/7]

SOFA_TYPE_API std::istream & sofa::type::vector< int >::read ( std::istream &  in)

Specialization for reading vectors of int and unsigned int using "A-B" notation for all integers between A and B.

◆ read() [5/7]

SOFA_TYPE_API std::istream & sofa::type::vector< unsigned int >::read ( std::istream &  in)

◆ read() [6/7]

SOFA_TYPE_API std::istream & sofa::type::vector< unsigned char >::read ( std::istream &  in)

◆ read() [7/7]

template<class T , class MemoryManager = CPUMemoryManager<T>>
std::istream& sofa::type::vector< T, MemoryManager >::read ( std::istream &  in)
inline

◆ write() [1/5]

SOFA_TYPE_API std::ostream & sofa::type::vector< unsigned char >::write ( std::ostream &  os) const

Output stream Specialization for writing vectors of unsigned char

◆ write() [2/5]

SOFA_TYPE_API std::ostream & sofa::type::vector< unsigned char >::write ( std::ostream &  os) const

Specialization for writing vectors of unsigned char.

◆ write() [3/5]

SOFA_TYPE_API std::ostream & sofa::type::vector< std::string >::write ( std::ostream &  os) const

Output stream Specialization for writing vectors of unsigned char

◆ write() [4/5]

SOFA_TYPE_API std::ostream & sofa::type::vector< std::string >::write ( std::ostream &  os) const

◆ write() [5/5]

template<class T , class MemoryManager = CPUMemoryManager<T>>
std::ostream& sofa::type::vector< T, MemoryManager >::write ( std::ostream &  os) const
inline

Related details

◆ operator<<

template<class T , class MemoryManager = CPUMemoryManager<T>>
std::ostream& operator<< ( std::ostream &  os,
const vector< T, MemoryManager > &  vec 
)
friend

Output stream.

◆ operator>>

template<class T , class MemoryManager = CPUMemoryManager<T>>
std::istream& operator>> ( std::istream &  in,
vector< T, MemoryManager > &  vec 
)
friend

Input stream.