CbmRoot
Loading...
Searching...
No Matches
cbm::algo::ca::Vector< T > Class Template Reference

#include <CaVector.h>

Inheritance diagram for cbm::algo::ca::Vector< T >:
[legend]
Collaboration diagram for cbm::algo::ca::Vector< T >:
[legend]

Public Types

typedef std::vector< T > Tbase
 

Public Member Functions

template<typename... Tinput>
 Vector (Tinput... value)
 Generic constructor from vairadic parameter list.
 
template<typename... Tinput>
 Vector (const char *name, Tinput... value)
 Generic constructor from vairadic parameter list including the name of the vector.
 
 Vector (const std::string &name, std::initializer_list< T > init)
 Constructor to make initializations like ca::Vector<int> myVector {"MyVector", {1, 2, 3}}.
 
 Vector (const Vector &v)
 Copy constructor.
 
 Vector (Vector &&v) noexcept
 Move constructor.
 
Vectoroperator= (const Vector &v)
 Copy assignment operator.
 
Vectoroperator= (Vector &&v) noexcept
 Move assignment operator.
 
void swap (Vector &v) noexcept
 Swap operator.
 
void SetName (const std::string &s)
 Sets the name of the vector.
 
void SetName (const std::basic_ostream< char > &s)
 Sets the name of the vector.
 
std::string GetName () const
 Gets name of the vector.
 
template<typename... Tinput>
void reset (std::size_t count, Tinput... value)
 Clears vector and resizes it to the selected size with selected values.
 
template<typename... Tinput>
void enlarge (std::size_t count, Tinput... value)
 Enlarges the vector to the new size.
 
void shrink (std::size_t count)
 Reduces the vector to a given size.
 
void reserve (std::size_t count)
 Reserves a new size for the vector.
 
template<typename Tinput >
void push_back (Tinput value)
 Pushes back a value to the vector.
 
template<typename Tinput >
void push_back_no_warning (Tinput value)
 Pushes back a value to the vector without testing for the memory re-alocation.
 
template<typename... Tinput>
void emplace_back (Tinput &&... value)
 Creates a parameter in the end of the vector.
 
T & operator[] (std::size_t pos)
 Mutable access to the element by its index.
 
const T & operator[] (std::size_t pos) const
 Constant access to the element by its index.
 
T & back ()
 Mutable access to the last element of the vector.
 
const T & back () const
 Constant access to the last element of the vector.
 

Private Member Functions

template<class Archive >
void serialize (Archive &ar, const unsigned int)
 Serialization function for the vector.
 

Private Attributes

std::string fName {"no name"}
 Name of the vector.
 

Friends

class boost::serialization::access
 

Detailed Description

template<class T>
class cbm::algo::ca::Vector< T >

ca::Vector class is a wrapper around std::vector. It does the following:

  1. gives names to vectors for better debugging
  2. controls the out-of-range access in debug mode
  3. supresses methods that are currently not controlled
  4. warns when slow memory operations are called, i.e. when the preallocated capacity is reached and the entire vector should be copied to a new place
  5. blocks usage of boolean vectors, as they have a special space-optimized but slow implementation in std. (Use ca::Vector<char> instead).

Definition at line 38 of file CaVector.h.

Member Typedef Documentation

◆ Tbase

template<class T >
std::vector<T> cbm::algo::ca::Vector< T >::Tbase

Definition at line 42 of file CaVector.h.

Constructor & Destructor Documentation

◆ Vector() [1/5]

template<class T >
template<typename... Tinput>
cbm::algo::ca::Vector< T >::Vector ( Tinput... value)
inline

Generic constructor from vairadic parameter list.

Definition at line 46 of file CaVector.h.

◆ Vector() [2/5]

template<class T >
template<typename... Tinput>
cbm::algo::ca::Vector< T >::Vector ( const char * name,
Tinput... value )
inline

Generic constructor from vairadic parameter list including the name of the vector.

Definition at line 52 of file CaVector.h.

◆ Vector() [3/5]

template<class T >
cbm::algo::ca::Vector< T >::Vector ( const std::string & name,
std::initializer_list< T > init )
inline

Constructor to make initializations like ca::Vector<int> myVector {"MyVector", {1, 2, 3}}.

Definition at line 58 of file CaVector.h.

◆ Vector() [4/5]

template<class T >
cbm::algo::ca::Vector< T >::Vector ( const Vector< T > & v)
inline

Copy constructor.

Definition at line 61 of file CaVector.h.

References v.

◆ Vector() [5/5]

template<class T >
cbm::algo::ca::Vector< T >::Vector ( Vector< T > && v)
inlinenoexcept

Move constructor.

Definition at line 64 of file CaVector.h.

Member Function Documentation

◆ back() [1/2]

template<class T >
T & cbm::algo::ca::Vector< T >::back ( )
inline

Mutable access to the last element of the vector.

Definition at line 230 of file CaVector.h.

References cbm::algo::ca::Vector< T >::fName.

Referenced by cbm::algo::ca::CloneMerger::Exec().

◆ back() [2/2]

template<class T >
const T & cbm::algo::ca::Vector< T >::back ( ) const
inline

Constant access to the last element of the vector.

Definition at line 240 of file CaVector.h.

References cbm::algo::ca::Vector< T >::fName.

◆ emplace_back()

template<class T >
template<typename... Tinput>
void cbm::algo::ca::Vector< T >::emplace_back ( Tinput &&... value)
inline

Creates a parameter in the end of the vector.

Parameters
valueVariadic list of the parameters, which are passed to the element constructor

Definition at line 196 of file CaVector.h.

References cbm::algo::ca::Vector< T >::fName.

Referenced by cbm::algo::ca::TripletConstructor::SelectTriplets(), and cbm::ca::TimeSliceReader::StoreHitRecord().

◆ enlarge()

template<class T >
template<typename... Tinput>
void cbm::algo::ca::Vector< T >::enlarge ( std::size_t count,
Tinput... value )
inline

Enlarges the vector to the new size.

Parameters
countNew size of the vector
valueValue of the new elements

Definition at line 133 of file CaVector.h.

References cbm::algo::ca::Vector< T >::fName.

Referenced by cbm::algo::ca::TrackExtender::FindMoreHits().

◆ GetName()

template<class T >
std::string cbm::algo::ca::Vector< T >::GetName ( ) const
inline

Gets name of the vector.

Definition at line 110 of file CaVector.h.

References cbm::algo::ca::Vector< T >::fName.

Referenced by cbm::ca::TimeSliceReader::SortQaHits().

◆ operator=() [1/2]

template<class T >
Vector & cbm::algo::ca::Vector< T >::operator= ( const Vector< T > & v)
inline

Copy assignment operator.

Definition at line 67 of file CaVector.h.

References cbm::algo::ca::Vector< T >::fName, and v.

◆ operator=() [2/2]

template<class T >
Vector & cbm::algo::ca::Vector< T >::operator= ( Vector< T > && v)
inlinenoexcept

Move assignment operator.

Definition at line 78 of file CaVector.h.

References cbm::algo::ca::Vector< T >::fName, and v.

◆ operator[]() [1/2]

template<class T >
T & cbm::algo::ca::Vector< T >::operator[] ( std::size_t pos)
inline

Mutable access to the element by its index.

Parameters
posIndex of the element

Definition at line 207 of file CaVector.h.

References cbm::algo::ca::Vector< T >::fName, and pos.

◆ operator[]() [2/2]

template<class T >
const T & cbm::algo::ca::Vector< T >::operator[] ( std::size_t pos) const
inline

Constant access to the element by its index.

Parameters
posIndex of the element

Definition at line 219 of file CaVector.h.

References cbm::algo::ca::Vector< T >::fName, and pos.

◆ push_back()

◆ push_back_no_warning()

template<class T >
template<typename Tinput >
void cbm::algo::ca::Vector< T >::push_back_no_warning ( Tinput value)
inline

◆ reserve()

◆ reset()

template<class T >
template<typename... Tinput>
void cbm::algo::ca::Vector< T >::reset ( std::size_t count,
Tinput... value )
inline

◆ serialize()

template<class T >
template<class Archive >
void cbm::algo::ca::Vector< T >::serialize ( Archive & ar,
const unsigned int  )
inlineprivate

Serialization function for the vector.

Definition at line 271 of file CaVector.h.

References cbm::algo::ca::Vector< T >::fName.

◆ SetName() [1/2]

template<class T >
void cbm::algo::ca::Vector< T >::SetName ( const std::basic_ostream< char > & s)
inline

Sets the name of the vector.

Parameters
sName of the vector (string stream)

Definition at line 102 of file CaVector.h.

References cbm::algo::ca::Vector< T >::fName.

◆ SetName() [2/2]

template<class T >
void cbm::algo::ca::Vector< T >::SetName ( const std::string & s)
inline

Sets the name of the vector.

Parameters
sName of the vector

Definition at line 98 of file CaVector.h.

References cbm::algo::ca::Vector< T >::fName.

Referenced by cbm::ca::TimeSliceReader::SortQaHits().

◆ shrink()

template<class T >
void cbm::algo::ca::Vector< T >::shrink ( std::size_t count)
inline

Reduces the vector to a given size.

Parameters
countSize of the new vector

Definition at line 150 of file CaVector.h.

References cbm::algo::ca::Vector< T >::fName.

Referenced by cbm::algo::ca::TripletConstructor::FindDoublets(), cbm::algo::ca::DataManager::InitData(), and cbm::algo::ca::Grid::RemoveUsedHits().

◆ swap()

template<class T >
void cbm::algo::ca::Vector< T >::swap ( Vector< T > & v)
inlinenoexcept

Swap operator.

Definition at line 88 of file CaVector.h.

References cbm::algo::ca::Vector< T >::fName, and v.

Friends And Related Symbol Documentation

◆ boost::serialization::access

template<class T >
friend class boost::serialization::access
friend

Definition at line 39 of file CaVector.h.

Member Data Documentation

◆ fName


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