00001 #ifndef DCHAIN_LABELEDPARTICLELIST_CC
00002 #define DCHAIN_LABELEDPARTICLELIST_CC
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083 #include <algorithm>
00084 #include <stdlib.h>
00085
00086
00087 #include "DecayChain/Element/LabeledParticle.h"
00088 #include "DecayChain/Iterator/MuteWholeItr.h"
00089 #include "DecayChain/Iterator/WholeItr.h"
00090 #include "DecayChain/Iterator/PartialItr.h"
00091
00092 #include "DecayChain/List/LabeledParticleList.h"
00093
00094
00095
00096
00097 namespace dchain {
00098
00099
00100
00101
00102
00103
00104
00105 template < class ParticleClass , class CandidateClass >
00106 LabeledParticleList< ParticleClass , CandidateClass >::LabeledParticleList() :
00107 m_list( *(new _labeledparticlelist_vector_ ) )
00108 {
00109 }
00110
00111
00112
00113
00114
00115
00116 template < class ParticleClass , class CandidateClass >
00117 LabeledParticleList< ParticleClass , CandidateClass >::~LabeledParticleList()
00118 {
00119 delete( &m_list ) ;
00120 }
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136 template < class ParticleClass , class CandidateClass >
00137 LabeledParticle< ParticleClass >& LabeledParticleList< ParticleClass , CandidateClass >::operator[]( const int aIndex ) {
00138 return ( labeledParticleClass( aIndex ) ) ;
00139 }
00140
00141
00142
00143 template < class ParticleClass , class CandidateClass >
00144 typename LabeledParticleList< ParticleClass , CandidateClass >::iterator LabeledParticleList< ParticleClass , CandidateClass >::begin()
00145 {
00146 return ( iterator( this , 0 ) ) ;
00147 }
00148
00149
00150
00151 template < class ParticleClass , class CandidateClass >
00152 typename LabeledParticleList< ParticleClass , CandidateClass >::iterator LabeledParticleList< ParticleClass , CandidateClass >::end()
00153 {
00154 return ( iterator( this , m_list.size() ) ) ;
00155 }
00156
00157
00158
00159 template < class ParticleClass , class CandidateClass >
00160 void LabeledParticleList< ParticleClass , CandidateClass >::push_back( const LabeledParticle< ParticleClass >& aEntry )
00161 {
00162 m_list.push_back( aEntry ) ;
00163 }
00164
00165
00166
00167 template < class ParticleClass , class CandidateClass >
00168 void LabeledParticleList< ParticleClass , CandidateClass >::erase_elements( int aStart ,
00169 int aFinish )
00170 {
00171 m_list.erase( m_list.begin() + aStart ,
00172 m_list.begin() + aFinish ) ;
00173 }
00174
00175
00176
00177 template < class ParticleClass , class CandidateClass >
00178 LabeledCandidate< CandidateClass >& LabeledParticleList< ParticleClass , CandidateClass >::labeledCandidateClass( const int aIndex )
00179 {
00180 return ( labeledParticleClass( aIndex ) ) ;
00181 }
00182
00183
00184
00185 template < class ParticleClass , class CandidateClass >
00186 LabeledParticle< ParticleClass >& LabeledParticleList< ParticleClass , CandidateClass >::labeledParticleClass( const int aIndex )
00187 {
00188 return ( m_list[ aIndex ] ) ;
00189 }
00190
00191
00192
00193
00194
00195
00196
00197 template < class ParticleClass , class CandidateClass >
00198 const LabeledParticle< ParticleClass >& LabeledParticleList< ParticleClass , CandidateClass >::operator[]( const int aIndex ) const
00199 {
00200 return ( labeledParticleClass( aIndex ) ) ;
00201 }
00202
00203
00204
00205 template < class ParticleClass , class CandidateClass >
00206 bool LabeledParticleList< ParticleClass , CandidateClass >::empty() const
00207 {
00208 return ( m_list.empty() ) ;
00209 }
00210
00211
00212
00213 template < class ParticleClass , class CandidateClass >
00214 bool LabeledParticleList< ParticleClass , CandidateClass >::empty( const conjugation::Label aLabel ) const
00215 {
00216
00217 if ( m_list.empty() ) {
00218 return ( !false ) ;
00219 }
00220 return ( const_partial_iterator( this , 0 , aLabel ) ==
00221 const_partial_iterator( this , m_list.size() , aLabel ) ) ;
00222 }
00223
00224
00225
00226 template < class ParticleClass , class CandidateClass >
00227 int LabeledParticleList< ParticleClass , CandidateClass >::size() const
00228 {
00229 return ( m_list.size() ) ;
00230 }
00231
00232
00233
00234 template < class ParticleClass , class CandidateClass >
00235 int LabeledParticleList< ParticleClass , CandidateClass >::size( const conjugation::Label aLabel ) const
00236 {
00237
00238 if ( m_list.empty() ) {
00239 return ( 0 ) ;
00240 }
00241 int result( 0 ) ;
00242
00243
00244
00245
00246
00247
00248
00249 typename _labeledparticlelist_vector_::const_iterator first( m_list.begin() ) ;
00250 typename _labeledparticlelist_vector_::const_iterator last( m_list.end() ) ;
00251 while (first != last) {
00252 if ( *first == aLabel ) {
00253 first++ ;
00254 result++ ;
00255 }
00256 }
00257
00258 return ( result ) ;
00259 }
00260
00261
00262
00263 template < class ParticleClass , class CandidateClass >
00264 typename LabeledParticleList< ParticleClass , CandidateClass >::const_iterator LabeledParticleList< ParticleClass , CandidateClass >::begin() const
00265 {
00266 return ( const_iterator( this , 0 ) ) ;
00267 }
00268
00269
00270
00271 template < class ParticleClass , class CandidateClass >
00272 typename LabeledParticleList< ParticleClass , CandidateClass >::const_partial_iterator LabeledParticleList< ParticleClass , CandidateClass >::begin( const conjugation::Label aLabel ) const
00273 {
00274 return ( const_partial_iterator( this , 0 , aLabel ) ) ;
00275 }
00276
00277
00278
00279 template < class ParticleClass , class CandidateClass >
00280 typename LabeledParticleList< ParticleClass , CandidateClass >::const_iterator LabeledParticleList< ParticleClass , CandidateClass >::end() const
00281 {
00282 return ( const_iterator( this , m_list.size() ) ) ;
00283 }
00284
00285
00286
00287 template < class ParticleClass , class CandidateClass >
00288 typename LabeledParticleList< ParticleClass , CandidateClass >::const_partial_iterator LabeledParticleList< ParticleClass , CandidateClass >::end( const conjugation::Label aLabel ) const
00289 {
00290 return ( const_partial_iterator( this , m_list.size() , aLabel ) ) ;
00291 }
00292
00293
00294
00295 template < class ParticleClass , class CandidateClass >
00296 const LabeledCandidate< CandidateClass >& LabeledParticleList< ParticleClass , CandidateClass >::labeledCandidateClass( const int aIndex ) const
00297 {
00298 return ( labeledParticleClass( aIndex ) ) ;
00299 }
00300
00301
00302
00303 template < class ParticleClass , class CandidateClass >
00304 const LabeledParticle< ParticleClass >& LabeledParticleList< ParticleClass , CandidateClass >::labeledParticleClass( const int aIndex ) const
00305 {
00306 return ( m_list[ aIndex ] ) ;
00307 }
00308
00309
00310
00311
00312 }
00313 #endif