ATLAS Offline Software
Loading...
Searching...
No Matches
Trk::IntVec Class Reference

#include <IntVec.h>

Collaboration diagram for Trk::IntVec:

Public Member Functions

 IntVec ()
 IntVec (int)
 IntVec (int, int)
 IntVec (const IntVec &)
 ~IntVec ()
int & operator[] (int)
const int & operator[] (int) const
IntVecoperator= (const IntVec &)
IntVec operator+ (const IntVec &)
IntVecoperator+= (const IntVec &)
IntVec operator- (const IntVec &)
IntVecoperator-= (const IntVec &)
void reSize (int)
int n_elem () const

Private Attributes

int m_Nele
int * m_ptr_data

Detailed Description

Definition at line 10 of file IntVec.h.

Constructor & Destructor Documentation

◆ IntVec() [1/4]

Trk::IntVec::IntVec ( )

Definition at line 13 of file IntVec.cxx.

14 : m_Nele(0), m_ptr_data(nullptr)
15{}
int * m_ptr_data
Definition IntVec.h:31
int m_Nele
Definition IntVec.h:30

◆ IntVec() [2/4]

Trk::IntVec::IntVec ( int N)

Definition at line 17 of file IntVec.cxx.

18 : m_Nele(N)
19 , m_ptr_data(new int[m_Nele])
20{
21
22 for(int i=0;i<m_Nele;i++)
23 *(m_ptr_data+i)=0;
24}

◆ IntVec() [3/4]

Trk::IntVec::IntVec ( int N,
int init )

Definition at line 26 of file IntVec.cxx.

27 : m_Nele(N)
28 , m_ptr_data(new int[m_Nele])
29{
30
31 for(int i=0;i<m_Nele;i++)
32 *(m_ptr_data+i)=init;
33}
init(v_theApp, v_rootStream=None)
Definition PyKernel.py:45

◆ IntVec() [4/4]

Trk::IntVec::IntVec ( const IntVec & v)

Definition at line 35 of file IntVec.cxx.

36 : m_Nele(v.m_Nele)
37 , m_ptr_data(new int[m_Nele])
38{
39
40 for(int i=0;i<m_Nele;i++)
41 *(m_ptr_data+i)=v[i];
42}
@ v
Definition ParamDefs.h:78

◆ ~IntVec()

Trk::IntVec::~IntVec ( )

Definition at line 44 of file IntVec.cxx.

44 {
45 delete [] m_ptr_data;
46}

Member Function Documentation

◆ n_elem()

int Trk::IntVec::n_elem ( ) const
inline

Definition at line 27 of file IntVec.h.

27{ return m_Nele; }

◆ operator+()

IntVec Trk::IntVec::operator+ ( const IntVec & v)

Definition at line 84 of file IntVec.cxx.

84 {
85 if( m_Nele != v.m_Nele ) {
86 throw std::range_error( "operator+: vectors size does not match!" );
87 }
88
90 for (int i=0;i<m_Nele;i++)
91 b[i] = *(m_ptr_data+i) + v[i];
92
93 return b;
94}

◆ operator+=()

IntVec & Trk::IntVec::operator+= ( const IntVec & v)

Definition at line 96 of file IntVec.cxx.

96 {
97 if( m_Nele != v.m_Nele ) {
98 throw std::range_error( "operator+=: vectors size does not match!" );
99 }
100
101 for (int i=0;i<m_Nele;i++)
102 *(m_ptr_data+i)+=v[i];
103
104 return *this;
105}

◆ operator-()

IntVec Trk::IntVec::operator- ( const IntVec & v)

Definition at line 107 of file IntVec.cxx.

107 {
108 if( m_Nele != v.m_Nele ) {
109 throw std::range_error( "operator+: vectors size does not match!" );
110 }
111
112 IntVec b(m_Nele);
113 for (int i=0;i<m_Nele;i++)
114 b[i] = *(m_ptr_data+i) - v[i];
115
116 return b;
117}

◆ operator-=()

IntVec & Trk::IntVec::operator-= ( const IntVec & v)

Definition at line 119 of file IntVec.cxx.

119 {
120 if( m_Nele != v.m_Nele ) {
121 throw std::range_error( "operator+=: vectors size does not match!" );
122 }
123
124 for (int i=0;i<m_Nele;i++)
125 *(m_ptr_data+i)-=v[i];
126
127 return *this;
128}

◆ operator=()

IntVec & Trk::IntVec::operator= ( const IntVec & v)

Definition at line 48 of file IntVec.cxx.

48 {
49 if(m_Nele!=0 && m_Nele!=v.m_Nele) {
50 throw std::range_error( "IntVec Assignment: size does not match!" );
51 }
52
53 if ( m_ptr_data != v.m_ptr_data ) {
54 reSize(v.m_Nele);
55 for(int i=0;i<m_Nele;i++)
56 *(m_ptr_data+i)=v[i];
57 }
58
59 return *this;
60}
void reSize(int)
Definition IntVec.cxx:131

◆ operator[]() [1/2]

int & Trk::IntVec::operator[] ( int i)

Definition at line 62 of file IntVec.cxx.

62 {
63 if(i<0) {
64 throw std::out_of_range( "IntVec: Index < zero! " );
65 }
66 else if(i>=m_Nele) {
67 throw std::out_of_range( "IntVec: Index too large! " );
68 }
69
70 return *(m_ptr_data+i);
71}

◆ operator[]() [2/2]

const int & Trk::IntVec::operator[] ( int i) const

Definition at line 73 of file IntVec.cxx.

73 {
74 if(i<0) {
75 throw std::out_of_range( "IntVec: Index < zero! " );
76 }
77 else if(i>=m_Nele) {
78 throw std::out_of_range( "IntVec: Index too large! " );
79 }
80
81 return *(m_ptr_data+i);
82}

◆ reSize()

void Trk::IntVec::reSize ( int Nnew)

Definition at line 131 of file IntVec.cxx.

131 {
132 if ( Nnew>=0 && Nnew != m_Nele ) {
133 int* p = m_ptr_data;
134 int Nele_old = m_Nele;
135 m_ptr_data = new int[Nnew];
136 m_Nele = Nnew;
137 int k = m_Nele <= Nele_old ? m_Nele : Nele_old;
138
139 p += k;
140 int* q = m_ptr_data + k;
141 while (q > m_ptr_data)
142 *(--q) = *(--p);
143
144 delete [] p;
145 }
146}

Member Data Documentation

◆ m_Nele

int Trk::IntVec::m_Nele
private

Definition at line 30 of file IntVec.h.

◆ m_ptr_data

int* Trk::IntVec::m_ptr_data
private

Definition at line 31 of file IntVec.h.


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