#include <G4TrackList.hh>
Public Types | |
typedef G4TrackList_iterator | iterator |
Public Member Functions | |
G4TrackList () | |
~G4TrackList () | |
G4Track * | back () |
G4int | size () const |
bool | empty () const |
iterator | insert (iterator, G4Track *) |
iterator | begin () |
iterator | end () |
bool | Holds (const G4Track *) const |
void | push_front (G4Track *__track) |
void | push_back (G4Track *__track) |
G4Track * | pop_back () |
void | remove (G4Track *) |
iterator | pop (G4Track *) |
iterator | pop (iterator __first, iterator __last) |
iterator | erase (G4Track *) |
iterator | erase (iterator __first, iterator __last) |
void | transferTo (G4TrackList *) |
Protected Member Functions | |
G4TrackListNode * | CreateNode (G4Track *) |
G4TrackListNode * | Flag (G4Track *) |
G4TrackListNode * | Unflag (G4Track *) |
void | CheckFlag (G4TrackListNode *) |
void | DeleteTrack (G4Track *) |
void | Hook (G4TrackListNode *, G4TrackListNode *) |
void | Unhook (G4TrackListNode *) |
G4TrackListNode * | EraseTrackListNode (G4Track *) |
Definition at line 106 of file G4TrackList.hh.
Definition at line 120 of file G4TrackList.hh.
G4TrackList::G4TrackList | ( | ) |
Definition at line 77 of file G4TrackList.cc.
References G4TrackListNode::fAttachedToList, G4TrackListNode::SetNext(), and G4TrackListNode::SetPrevious().
00077 : fBoundary() 00078 { 00079 fListRef = new _ListRef(this); 00080 fpStart = 0; 00081 fpFinish = 0; 00082 fNbTracks = 0 ; 00083 fBoundary.SetPrevious(&fBoundary); 00084 fBoundary.SetNext(&fBoundary); 00085 fBoundary.fAttachedToList = true; 00086 }
G4TrackList::~G4TrackList | ( | ) |
Definition at line 107 of file G4TrackList.cc.
References DeleteTrack(), G4TrackListNode::GetNext(), and G4TrackListNode::GetTrack().
00108 { 00109 if( fNbTracks != 0 ) 00110 { 00111 G4TrackListNode * __stackedTrack = fpStart; 00112 G4TrackListNode * __nextStackedTrack; 00113 00114 // delete tracks in the stack 00115 while( __stackedTrack && __stackedTrack != &(fBoundary) ) 00116 { 00117 __nextStackedTrack = __stackedTrack->GetNext(); 00118 G4Track* __track = __stackedTrack->GetTrack(); 00119 00120 delete __stackedTrack; 00121 __stackedTrack = 0; 00122 00123 if(__track) 00124 { 00126 DeleteTrack(__track); 00127 __track = 0; 00129 } 00130 00131 __stackedTrack = __nextStackedTrack; 00132 } 00133 } 00134 fNbTracks = 0; 00135 }
G4Track* G4TrackList::back | ( | ) | [inline] |
Definition at line 125 of file G4TrackList.hh.
References G4TrackListNode::GetTrack().
00126 { 00127 if(fNbTracks != 0) 00128 return fpFinish->GetTrack(); 00129 else return 0 ; 00130 }
G4TrackList::iterator G4TrackList::begin | ( | ) | [inline] |
Definition at line 271 of file G4TrackList.hh.
Referenced by push_front().
00272 { return iterator(fpStart); }
void G4TrackList::CheckFlag | ( | G4TrackListNode * | ) | [protected] |
Definition at line 269 of file G4TrackList.cc.
References FatalErrorInArgument, G4endl, G4Exception(), GetIT(), G4IT::GetName(), G4TrackListNode::GetTrack(), and G4Track::GetTrackID().
Referenced by Unflag().
00270 { 00271 if(__trackListNode -> fListRef->fpTrackList != this) 00272 { 00273 G4Track* track = __trackListNode->GetTrack(); 00274 G4ExceptionDescription exceptionDescription ; 00275 exceptionDescription 00276 << "The track "<< GetIT(track)->GetName() 00277 << " with trackID " << track->GetTrackID() 00278 << " is not correctly linked to a TrackList." 00279 << G4endl 00280 << "You are probably trying to withdraw this track " 00281 << "from the list but it probably does not belong to " 00282 << "this track list." << G4endl; 00283 G4Exception("G4TrackList::CheckFlag","G4TrackList002", 00284 FatalErrorInArgument,exceptionDescription); 00285 } 00286 }
G4TrackListNode * G4TrackList::CreateNode | ( | G4Track * | ) | [protected] |
Complexity = constant
Definition at line 170 of file G4TrackList.cc.
References Flag().
Referenced by insert().
00171 { 00172 G4TrackListNode* __trackListNode = Flag(__track); 00173 return __trackListNode; 00174 }
void G4TrackList::DeleteTrack | ( | G4Track * | ) | [protected] |
Definition at line 335 of file G4TrackList.cc.
References G4Step::DeleteSecondaryVector(), G4Step::GetfSecondary(), and G4Track::GetStep().
Referenced by erase(), and ~G4TrackList().
00336 { 00337 G4Step* __step = const_cast<G4Step*>(__track->GetStep()); 00338 if(__step) 00339 { 00340 if(__step->GetfSecondary()) __step->DeleteSecondaryVector(); 00341 delete __step; 00342 } 00343 delete __track; 00344 }
bool G4TrackList::empty | ( | ) | const [inline] |
G4TrackList::iterator G4TrackList::end | ( | ) | [inline] |
Definition at line 274 of file G4TrackList.hh.
Referenced by push_back().
00275 { return iterator( &(fBoundary) ); }
G4TrackList::iterator G4TrackList::erase | ( | iterator | __first, | |
iterator | __last | |||
) |
Complexity = constant By storing the node inside the object, we avoid searching through all the container.
Definition at line 377 of file G4TrackList.cc.
References erase().
00378 { 00379 if(fNbTracks == 0) return iterator(&fBoundary); 00380 00381 while (__first != __last) 00382 { 00383 if(__first . fpNode) 00384 __first = erase(*__first); 00385 } 00386 return __last; 00387 }
G4TrackList::iterator G4TrackList::erase | ( | G4Track * | ) |
Definition at line 346 of file G4TrackList.cc.
References DeleteTrack(), and EraseTrackListNode().
Referenced by erase(), and remove().
00347 { 00348 G4TrackListNode* __next_node = EraseTrackListNode(__track); 00350 DeleteTrack(__track); 00351 __track = 0; 00353 iterator __next(__next_node); 00354 return __next; 00355 }
G4TrackListNode * G4TrackList::EraseTrackListNode | ( | G4Track * | ) | [protected] |
Definition at line 325 of file G4TrackList.cc.
References GetIT(), G4TrackListNode::GetNext(), G4IT::SetTrackListNode(), Unflag(), and Unhook().
Referenced by erase().
00326 { 00327 G4TrackListNode* __node = Unflag(__track); 00328 GetIT(__track)->SetTrackListNode(0); 00329 G4TrackListNode* __next = __node->GetNext(); 00330 Unhook(__node); 00331 delete __node; 00332 return __next; 00333 }
G4TrackListNode * G4TrackList::Flag | ( | G4Track * | ) | [protected] |
Definition at line 142 of file G4TrackList.cc.
References FatalErrorInArgument, G4TrackListNode::fAttachedToList, G4TrackListNode::fListRef, G4Exception(), GetIT(), G4IT::GetName(), G4IT::GetTrackListNode(), and G4IT::SetTrackListNode().
Referenced by CreateNode().
00143 { 00144 G4IT* __iTrack = GetIT(__track); 00145 G4TrackListNode* __trackListNode = __iTrack->GetTrackListNode(); 00146 00147 if(__trackListNode != 0) 00148 { 00149 // Suggestion move the node to this list 00150 if(__trackListNode->fAttachedToList) 00151 { 00152 G4ExceptionDescription exceptionDescription ; 00153 exceptionDescription << "This track "<< __iTrack->GetName() ; 00154 exceptionDescription << " is already attached to a TrackList "; 00155 G4Exception("G4TrackList::Flag","G4TrackList001", 00156 FatalErrorInArgument,exceptionDescription); 00157 } 00158 } 00159 else 00160 { 00161 __trackListNode = new G4TrackListNode(__track); 00162 __iTrack->SetTrackListNode(__trackListNode); 00163 } 00164 00165 __trackListNode->fAttachedToList = true; 00166 __trackListNode->fListRef = fListRef; 00167 return __trackListNode; 00168 }
bool G4TrackList::Holds | ( | const G4Track * | ) | const |
return an iterator that contains an empty node use for boundary checking only
Definition at line 137 of file G4TrackList.cc.
References GetIT().
00138 { 00139 return (GetIT(track)->GetTrackListNode()->fListRef->fpTrackList == this) ; 00140 }
void G4TrackList::Hook | ( | G4TrackListNode * | , | |
G4TrackListNode * | ||||
) | [protected] |
Definition at line 176 of file G4TrackList.cc.
References G4TrackListNode::GetPrevious(), G4TrackListNode::SetNext(), and G4TrackListNode::SetPrevious().
Referenced by insert().
00177 { 00178 if(fNbTracks == 0) 00179 { 00180 // DEBUG 00181 // G4cout << "fNbTracks == 0" << G4endl; 00182 fpStart = __toHook; 00183 fpFinish = __toHook; 00184 __toHook->SetNext(&fBoundary); 00185 __toHook->SetPrevious(&fBoundary); 00186 fBoundary.SetNext(__toHook); 00187 fBoundary.SetPrevious(__toHook); 00188 } 00189 else if( __position == &fBoundary) 00190 { 00191 // DEBUG 00192 // G4cout << "__position == &fBoundary" << G4endl; 00193 fpFinish->SetNext( __toHook ); 00194 __toHook->SetPrevious( fpFinish ); 00195 00196 __toHook->SetNext(&fBoundary); 00197 fBoundary.SetPrevious( __toHook ); 00198 00199 fpFinish = __toHook; 00200 } 00201 else if( __position == fpStart ) 00202 { 00203 // DEBUG 00204 // G4cout << "__position == fStart" << G4endl; 00205 __toHook->SetPrevious( &fBoundary ); 00206 fBoundary.SetNext(__toHook); 00207 __toHook->SetNext(fpStart); 00208 fpStart->SetPrevious(__toHook); 00209 fpStart = __toHook; 00210 } 00211 else 00212 { 00213 // DEBUG 00214 // G4cout << "else" << G4endl; 00215 G4TrackListNode* __previous = __position->GetPrevious(); 00216 __toHook->SetPrevious(__previous); 00217 __toHook->SetNext(__position); 00218 __position->SetPrevious(__toHook); 00219 __previous->SetNext(__toHook); 00220 } 00221 00222 fNbTracks++; 00223 }
G4TrackList::iterator G4TrackList::insert | ( | iterator | , | |
G4Track * | ||||
) |
Definition at line 258 of file G4TrackList.cc.
References CreateNode(), G4TrackList_iterator::fpNode, and Hook().
Referenced by push_back(), and push_front().
00259 { 00260 G4TrackListNode* __node = CreateNode(__track); 00261 Hook(__position.fpNode, __node); 00262 return iterator(__node); 00263 }
G4TrackList::iterator G4TrackList::pop | ( | iterator | __first, | |
iterator | __last | |||
) |
Definition at line 363 of file G4TrackList.cc.
References pop().
00364 { 00365 if(fNbTracks == 0) return iterator(&fBoundary); 00366 00367 while (__first != __last) 00368 { 00369 if(__first . fpNode) 00370 __first = pop(*__first); 00371 } 00372 return __last; 00373 }
G4TrackList::iterator G4TrackList::pop | ( | G4Track * | ) |
Definition at line 317 of file G4TrackList.cc.
References G4TrackListNode::GetNext(), Unflag(), and Unhook().
Referenced by pop().
00318 { 00319 G4TrackListNode* __node = Unflag(__track); 00320 iterator __next(__node->GetNext()); 00321 Unhook(__node); 00322 return __next; 00323 }
G4Track * G4TrackList::pop_back | ( | ) |
Definition at line 308 of file G4TrackList.cc.
References G4TrackListNode::GetTrack(), Unflag(), and Unhook().
00309 { 00310 if( fNbTracks == 0 ) return 0; 00311 G4TrackListNode * __aStackedTrack = fpFinish; 00312 Unhook( __aStackedTrack ); 00313 Unflag( __aStackedTrack->GetTrack() ); 00314 return __aStackedTrack->GetTrack(); 00315 }
void G4TrackList::push_back | ( | G4Track * | __track | ) | [inline] |
void G4TrackList::push_front | ( | G4Track * | __track | ) | [inline] |
void G4TrackList::remove | ( | G4Track * | ) |
Definition at line 357 of file G4TrackList.cc.
References erase().
00358 { 00359 this->erase(__track); 00360 }
G4int G4TrackList::size | ( | ) | const [inline] |
void G4TrackList::transferTo | ( | G4TrackList * | ) |
Complexity = linear in size between __first and __last
Definition at line 389 of file G4TrackList.cc.
References fBoundary, fNbTracks, fpFinish, fpStart, G4TrackListNode::SetNext(), and G4TrackListNode::SetPrevious().
00390 { 00391 if(fNbTracks==0) return; 00392 00393 if(__destination->fNbTracks == 0) 00394 { 00395 __destination->fpStart = this->fpStart ; 00396 __destination->fpFinish = this->fpFinish ; 00397 __destination->fNbTracks = this->fNbTracks; 00398 00399 __destination->fBoundary.SetNext(fpStart); 00400 __destination->fBoundary.SetPrevious(fpFinish); 00401 00402 __destination->fpFinish->SetNext(&__destination->fBoundary); 00403 __destination->fpStart->SetPrevious(&__destination->fBoundary); 00404 } 00405 else 00406 { 00407 this->fpStart->SetPrevious(__destination->fpFinish); 00408 __destination->fpFinish->SetNext(this->fpStart); 00409 __destination->fBoundary.SetPrevious(this->fpFinish); 00410 this->fpFinish->SetNext(&__destination->fBoundary); 00411 00412 __destination->fpFinish = this->fpFinish; 00413 __destination->fNbTracks += this->fNbTracks; 00414 } 00415 00416 fNbTracks = 0; 00417 fpStart = 0; 00418 fpFinish = 0; 00419 this->fBoundary.SetPrevious(&this->fBoundary); 00420 this->fBoundary.SetNext(&this->fBoundary); 00421 00422 fListRef->fpTrackList = __destination; 00423 }
G4TrackListNode * G4TrackList::Unflag | ( | G4Track * | ) | [protected] |
Definition at line 288 of file G4TrackList.cc.
References CheckFlag(), FatalErrorInArgument, G4TrackListNode::fAttachedToList, G4TrackListNode::fListRef, G4Exception(), GetIT(), G4IT::GetName(), and G4IT::GetTrackListNode().
Referenced by EraseTrackListNode(), pop(), and pop_back().
00289 { 00290 G4IT* __IT = GetIT(__track); 00291 G4TrackListNode* __trackListNode = __IT->GetTrackListNode(); 00292 // TODO : complete the exception 00293 if(__trackListNode == 0) 00294 { 00295 G4ExceptionDescription exceptionDescription ; 00296 exceptionDescription << "This track "<< GetIT(__track)->GetName() ; 00297 exceptionDescription << " was not connected to any trackList "; 00298 G4Exception("G4TrackList::Unflag","G4TrackList003", 00299 FatalErrorInArgument,exceptionDescription); 00300 return 0; 00301 } 00302 CheckFlag(__trackListNode); 00303 __trackListNode->fAttachedToList = false; 00304 __trackListNode->fListRef = 0; 00305 return __trackListNode; 00306 }
void G4TrackList::Unhook | ( | G4TrackListNode * | ) | [protected] |
Definition at line 225 of file G4TrackList.cc.
References G4TrackListNode::GetNext(), G4TrackListNode::GetPrevious(), G4TrackListNode::SetNext(), and G4TrackListNode::SetPrevious().
Referenced by EraseTrackListNode(), pop(), and pop_back().
00226 { 00227 G4TrackListNode* __previous = __toUnHook->GetPrevious(); 00228 G4TrackListNode* __next = __toUnHook->GetNext(); 00229 00230 __toUnHook->SetPrevious(0); 00231 __toUnHook->SetNext(0); 00232 00233 if( fNbTracks == 1 ) 00234 { 00235 fpStart = 0; 00236 fpFinish = 0; 00237 } 00238 else 00239 { 00240 if(__toUnHook == fpFinish) 00241 { 00242 fpFinish = __previous; 00243 } 00244 if(__toUnHook == fpStart) 00245 { 00246 fpStart = __next; 00247 } 00248 } 00249 00250 // There should be always a __next and a __previous 00251 // because it is a circle link 00252 __next->SetPrevious(__previous); 00253 __previous->SetNext(__next); 00254 00255 fNbTracks--; 00256 }