CbmRoot
Loading...
Searching...
No Matches
Vector< T > Class Template Reference

#include <CaVector.h>

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

Public Types

using Tbase = std::vector<T>
 
using value_type = T
 
using allocator_type = typename Tbase::allocator_type
 
using pointer = typename std::allocator_traits<allocator_type>::pointer
 
using const_pointer = typename std::allocator_traits<allocator_type>::const_pointer
 
using reference = value_type&
 
using const_reference = const value_type&
 
using size_type = typename Tbase::size_type
 
using difference_type = typename Tbase::difference_type
 
using iterator = typename Tbase::iterator
 
using const_iterator = typename Tbase::const_iterator
 
using reverse_iterator = std::reverse_iterator<iterator>
 
using const_reverse_iterator = std::reverse_iterator<const_iterator>
 

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 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 39 of file CaVector.h.

Member Typedef Documentation

◆ allocator_type

template<class T>
using cbm::algo::ca::Vector< T >::allocator_type = typename Tbase::allocator_type

Definition at line 45 of file CaVector.h.

◆ const_iterator

template<class T>
using cbm::algo::ca::Vector< T >::const_iterator = typename Tbase::const_iterator

Definition at line 53 of file CaVector.h.

◆ const_pointer

template<class T>
using cbm::algo::ca::Vector< T >::const_pointer = typename std::allocator_traits<allocator_type>::const_pointer

Definition at line 47 of file CaVector.h.

◆ const_reference

template<class T>
using cbm::algo::ca::Vector< T >::const_reference = const value_type&

Definition at line 49 of file CaVector.h.

◆ const_reverse_iterator

template<class T>
using cbm::algo::ca::Vector< T >::const_reverse_iterator = std::reverse_iterator<const_iterator>

Definition at line 55 of file CaVector.h.

◆ difference_type

template<class T>
using cbm::algo::ca::Vector< T >::difference_type = typename Tbase::difference_type

Definition at line 51 of file CaVector.h.

◆ iterator

template<class T>
using cbm::algo::ca::Vector< T >::iterator = typename Tbase::iterator

Definition at line 52 of file CaVector.h.

◆ pointer

template<class T>
using cbm::algo::ca::Vector< T >::pointer = typename std::allocator_traits<allocator_type>::pointer

Definition at line 46 of file CaVector.h.

◆ reference

template<class T>
using cbm::algo::ca::Vector< T >::reference = value_type&

Definition at line 48 of file CaVector.h.

◆ reverse_iterator

template<class T>
using cbm::algo::ca::Vector< T >::reverse_iterator = std::reverse_iterator<iterator>

Definition at line 54 of file CaVector.h.

◆ size_type

template<class T>
using cbm::algo::ca::Vector< T >::size_type = typename Tbase::size_type

Definition at line 50 of file CaVector.h.

◆ Tbase

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

Definition at line 43 of file CaVector.h.

◆ value_type

template<class T>
using cbm::algo::ca::Vector< T >::value_type = T

Definition at line 44 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 60 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 66 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 72 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 75 of file CaVector.h.

◆ Vector() [5/5]

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

Move constructor.

Definition at line 78 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 244 of file CaVector.h.

◆ 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 254 of file CaVector.h.

◆ 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 210 of file CaVector.h.

◆ 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 147 of file CaVector.h.

◆ GetName()

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

Gets name of the vector.

Definition at line 124 of file CaVector.h.

◆ operator=() [1/2]

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

Copy assignment operator.

Definition at line 81 of file CaVector.h.

◆ operator=() [2/2]

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

Move assignment operator.

Definition at line 92 of file CaVector.h.

◆ 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 221 of file CaVector.h.

◆ 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 233 of file CaVector.h.

◆ push_back()

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

Pushes back a value to the vector.

Parameters
valueNew value
Note
Raises a warning, if the vector re-alocates memory

Definition at line 190 of file CaVector.h.

Referenced by cbm::algo::ca::TrackFinderWindow::SelectTracks().

◆ push_back_no_warning()

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

Pushes back a value to the vector without testing for the memory re-alocation.

Parameters
valueNew value

Definition at line 202 of file CaVector.h.

◆ reserve()

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

Reserves a new size for the vector.

Parameters
countNew size of the vector

Definition at line 176 of file CaVector.h.

Referenced by cbm::algo::ca::TrackFinderWindow::ConstructTriplets(), and cbm::algo::ca::TrackFinderWindow::ReadWindowData().

◆ reset()

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

Clears vector and resizes it to the selected size with selected values.

Parameters
countNew size of the vector
valueVariadic list of the parameters to pass to the base std::vector::resize function

Definition at line 135 of file CaVector.h.

◆ 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 285 of file CaVector.h.

◆ 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 116 of file CaVector.h.

◆ 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 112 of file CaVector.h.

◆ 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 164 of file CaVector.h.

◆ swap()

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

Swap operator.

Definition at line 102 of file CaVector.h.

Friends And Related Symbol Documentation

◆ boost::serialization::access

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

Definition at line 40 of file CaVector.h.

Member Data Documentation

◆ fName

template<class T>
std::string cbm::algo::ca::Vector< T >::fName {"no name"}
private

Name of the vector.

Definition at line 278 of file CaVector.h.


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