Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4FastList< OBJECT > Class Template Reference

#include <G4FastList.hh>

Classes

class  TWatcher
 
class  Watcher
 

Public Types

using object = OBJECT
 
using iterator = G4FastList_iterator<OBJECT>
 
using const_iterator = G4FastList_const_iterator<OBJECT>
 
using node = G4FastListNode<OBJECT>
 

Public Member Functions

 G4FastList ()
 
 ~G4FastList ()
 
void SetListNode (G4FastListNode< G4FastList< OBJECT > > *__node)
 
G4FastListNode< G4FastList< OBJECT > > * GetListNode ()
 
void AddWatcher (Watcher *watcher)
 
void RemoveWatcher (Watcher *watcher)
 
OBJECT * back ()
 
G4int size () const
 
bool empty () const
 
iterator insert (iterator, OBJECT *)
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
bool Holds (const OBJECT *) const
 
void push_front (OBJECT *__track)
 
void push_back (OBJECT *__track)
 
OBJECT * pop_back ()
 
void remove (OBJECT *)
 
iterator pop (OBJECT *)
 
iterator pop (G4FastListNode< OBJECT > *)
 
iterator pop (iterator __first, iterator __last)
 
iterator erase (OBJECT *)
 
iterator erase (iterator __first, iterator __last)
 
void clear ()
 
void transferTo (G4FastList< OBJECT > *)
 
bool Holds (const G4Track *track) const
 SPECIFIC TO TRACKS.
 
G4FastListNode< G4Track > * GetNode (G4Track *__track)
 SPECIFIC TO TRACKS.
 
G4FastList< G4Track > * GetList (G4Track *__track)
 SPECIFIC TO TRACKS.
 
bool Holds (const G4Track *track) const
 SPECIFIC TO TRACKS.
 
G4FastListNode< G4Track > * GetNode (G4Track *__track)
 SPECIFIC TO TRACKS.
 
G4FastList< G4Track > * GetList (G4Track *__track)
 SPECIFIC TO TRACKS.
 

Static Public Member Functions

static G4FastListNode< OBJECT > * GetNode (OBJECT *)
 
static void SetNode (OBJECT *__obj, G4FastListNode< OBJECT > *__node)
 
static G4FastList< OBJECT > * GetList (OBJECT *)
 
static G4FastList< OBJECT > * GetList (G4FastListNode< OBJECT > *__trackListNode)
 
static void Pop (OBJECT *)
 

Protected Types

using WatcherSet
 

Protected Member Functions

G4FastListNode< OBJECT > * CreateNode (OBJECT *)
 
G4FastListNode< OBJECT > * Flag (OBJECT *)
 
G4FastListNode< OBJECT > * Unflag (OBJECT *)
 
void Unflag (G4FastListNode< OBJECT > *__trackListNode)
 
void CheckFlag (G4FastListNode< OBJECT > *)
 
void DeleteObject (OBJECT *)
 
void Hook (G4FastListNode< OBJECT > *, G4FastListNode< OBJECT > *)
 
void Unhook (G4FastListNode< OBJECT > *)
 
G4FastListNode< OBJECT > * EraseListNode (OBJECT *)
 
G4FastListNode< G4Track > * __GetNode (G4Track *__track)
 SPECIFIC TO TRACKS.
 
void DeleteObject (G4Track *__track)
 SPECIFIC TO TRACKS.
 
G4FastListNode< G4Track > * Flag (G4Track *__track)
 SPECIFIC TO TRACKS.
 
void CheckFlag (G4FastListNode< G4Track > *__trackListNode)
 SPECIFIC TO TRACKS.
 
G4FastListNode< G4Track > * EraseListNode (G4Track *__track)
 SPECIFIC TO TRACKS.
 
G4FastListNode< G4Track > * __GetNode (G4Track *__track)
 SPECIFIC TO TRACKS.
 
void DeleteObject (G4Track *__track)
 SPECIFIC TO TRACKS.
 
G4FastListNode< G4Track > * Flag (G4Track *__track)
 SPECIFIC TO TRACKS.
 
void CheckFlag (G4FastListNode< G4Track > *__trackListNode)
 SPECIFIC TO TRACKS.
 
G4FastListNode< G4Track > * EraseListNode (G4Track *__track)
 SPECIFIC TO TRACKS.
 

Static Protected Member Functions

static G4FastListNode< OBJECT > * __GetNode (OBJECT *)
 

Protected Attributes

G4int fNbObjects
 
G4shared_ptr< _ListRef< G4FastList< OBJECT > > > fListRef
 
G4FastListNode< OBJECT > fBoundary
 
WatcherSet fWatchers
 
G4FastListNode< G4FastList< OBJECT > > * fpNodeInManyLists
 

Detailed Description

template<class OBJECT>
class G4FastList< OBJECT >

G4FastList is used by G4TrackHolder to save G4IT tracks only. Its advantage lies to a fast search of a track in this list.

Definition at line 217 of file G4FastList.hh.

Member Typedef Documentation

◆ const_iterator

template<class OBJECT >
using G4FastList< OBJECT >::const_iterator = G4FastList_const_iterator<OBJECT>

Definition at line 321 of file G4FastList.hh.

◆ iterator

template<class OBJECT >
using G4FastList< OBJECT >::iterator = G4FastList_iterator<OBJECT>

Definition at line 320 of file G4FastList.hh.

◆ node

template<class OBJECT >
using G4FastList< OBJECT >::node = G4FastListNode<OBJECT>

Definition at line 322 of file G4FastList.hh.

◆ object

template<class OBJECT >
using G4FastList< OBJECT >::object = OBJECT

Definition at line 319 of file G4FastList.hh.

◆ WatcherSet

template<class OBJECT >
using G4FastList< OBJECT >::WatcherSet
protected
Initial value:
std::set<typename G4FastList<OBJECT>::Watcher*,

Definition at line 313 of file G4FastList.hh.

Constructor & Destructor Documentation

◆ G4FastList()

template<class OBJECT >
G4FastList< OBJECT >::G4FastList ( )

◆ ~G4FastList()

template<class OBJECT >
G4FastList< OBJECT >::~G4FastList ( )

Member Function Documentation

◆ __GetNode() [1/3]

G4FastListNode< G4Track > * G4FastList< G4Track >::__GetNode ( G4Track * __track)
protected

SPECIFIC TO TRACKS.

◆ __GetNode() [2/3]

G4FastListNode< G4Track > * G4FastList< G4Track >::__GetNode ( G4Track * __track)
protected

SPECIFIC TO TRACKS.

Definition at line 46 of file G4TrackList.cc.

47{
48 G4IT* __IT = GetIT(__track);
49 G4FastListNode<G4Track>* __trackListNode = __IT->GetListNode();
50 // TODO : complete the exception
51 if (__trackListNode == nullptr)
52 {
53 G4ExceptionDescription exceptionDescription;
54 exceptionDescription << "This track " << GetIT(__track)->GetName();
55 exceptionDescription << " was not connected to any trackList ";
56 G4Exception("G4FastList<OBJECT>::Unflag", "G4TrackList003", FatalErrorInArgument,
57 exceptionDescription);
58 return nullptr;
59 }
60 return __trackListNode;
61}
@ FatalErrorInArgument
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
G4IT * GetIT(const G4Track *track)
Definition G4IT.cc:48
Definition G4IT.hh:88
G4TrackListNode * GetListNode()
Definition G4IT.hh:148
virtual const G4String & GetName() const =0

◆ __GetNode() [3/3]

template<class OBJECT >
static G4FastListNode< OBJECT > * G4FastList< OBJECT >::__GetNode ( OBJECT * )
staticprotected

◆ AddWatcher()

template<class OBJECT >
void G4FastList< OBJECT >::AddWatcher ( Watcher * watcher)
inline

Definition at line 337 of file G4FastList.hh.

338 {
339 fWatchers.insert(watcher);
340 }
WatcherSet fWatchers

Referenced by G4ITTrackHolder::AddWatcher(), and G4FastList< OBJECT >::Watcher::Watch().

◆ back()

template<class OBJECT >
OBJECT * G4FastList< OBJECT >::back ( )
inline

Definition at line 349 of file G4FastList.hh.

350 {
351// if (fNbObjects != 0) return fpFinish->GetObject();
352 if (fNbObjects != 0) return fBoundary.GetPrevious()->GetObject();
353 return 0;
354 }
G4int fNbObjects
G4FastListNode< OBJECT > fBoundary

◆ begin() [1/2]

◆ begin() [2/2]

template<class OBJECT >
const_iterator G4FastList< OBJECT >::begin ( ) const
inline

◆ CheckFlag() [1/3]

void G4FastList< G4Track >::CheckFlag ( G4FastListNode< G4Track > * __trackListNode)
protected

SPECIFIC TO TRACKS.

◆ CheckFlag() [2/3]

void G4FastList< G4Track >::CheckFlag ( G4FastListNode< G4Track > * __trackListNode)
protected

SPECIFIC TO TRACKS.

Definition at line 129 of file G4TrackList.cc.

130{
131 if (__trackListNode->fListRef->fpList != this)
132 {
133 G4Track* track = __trackListNode->GetObject();
134 G4ExceptionDescription exceptionDescription;
135 exceptionDescription << "The track " << GetIT(track)->GetName()
136 << " with trackID " << track->GetTrackID()
137 << " is not correctly linked to a TrackList."
138 << G4endl
139 << "You are probably trying to withdraw this track "
140 << "from the list but it probably does not belong to "
141 << "this track list." << G4endl;
142 G4Exception("G4FastList<OBJECT>::CheckFlag", "G4FastList002",
143 FatalErrorInArgument, exceptionDescription);
144 }
145}
#define G4endl
Definition G4ios.hh:67
G4shared_ptr< _ListRef< G4FastList< OBJECT > > > fListRef
OBJECT * GetObject()
G4int GetTrackID() const

◆ CheckFlag() [3/3]

template<class OBJECT >
void G4FastList< OBJECT >::CheckFlag ( G4FastListNode< OBJECT > * )
protected

◆ clear()

template<class OBJECT >
void G4FastList< OBJECT >::clear ( )

Complexity = linear in size between __first and __last

Referenced by G4ManyFastLists< OBJECT >::RemoveLists().

◆ CreateNode()

template<class OBJECT >
G4FastListNode< OBJECT > * G4FastList< OBJECT >::CreateNode ( OBJECT * )
protected

◆ DeleteObject() [1/3]

void G4FastList< G4Track >::DeleteObject ( G4Track * __track)
protected

SPECIFIC TO TRACKS.

◆ DeleteObject() [2/3]

void G4FastList< G4Track >::DeleteObject ( G4Track * __track)
protected

SPECIFIC TO TRACKS.

Definition at line 65 of file G4TrackList.cc.

66{
67 if (G4AllocatorList::GetAllocatorListIfExist() == nullptr) return;
68
69 auto __step = const_cast<G4Step*>(__track->GetStep());
70 if (__step != nullptr)
71 {
72 if (__step->GetfSecondary() != nullptr)
73 __step->DeleteSecondaryVector();
74 delete __step;
75 }
76 delete __track;
77}
static G4AllocatorList * GetAllocatorListIfExist()
const G4Step * GetStep() const

◆ DeleteObject() [3/3]

template<class OBJECT >
void G4FastList< OBJECT >::DeleteObject ( OBJECT * )
protected

◆ empty()

◆ end() [1/2]

◆ end() [2/2]

template<class OBJECT >
const_iterator G4FastList< OBJECT >::end ( ) const
inline

◆ erase() [1/2]

template<class OBJECT >
iterator G4FastList< OBJECT >::erase ( iterator __first,
iterator __last )

Complexity = constant By storing the node inside the object, we avoid searching through all the container.

◆ erase() [2/2]

template<class OBJECT >
iterator G4FastList< OBJECT >::erase ( OBJECT * )

◆ EraseListNode() [1/3]

G4FastListNode< G4Track > * G4FastList< G4Track >::EraseListNode ( G4Track * __track)
protected

SPECIFIC TO TRACKS.

◆ EraseListNode() [2/3]

G4FastListNode< G4Track > * G4FastList< G4Track >::EraseListNode ( G4Track * __track)
protected

SPECIFIC TO TRACKS.

Definition at line 149 of file G4TrackList.cc.

150{
151 G4FastListNode<G4Track>* __node = Unflag(__track);
152 G4FastListNode<G4Track>* __next = __node->GetNext();
153 Unhook(__node);
154 __node->DetachYourSelf();
155 delete __node;
156 return __next;
157}
void DetachYourSelf()
G4FastListNode< OBJECT > * GetNext()
G4FastListNode< OBJECT > * Unflag(OBJECT *)
void Unhook(G4FastListNode< OBJECT > *)

◆ EraseListNode() [3/3]

template<class OBJECT >
G4FastListNode< OBJECT > * G4FastList< OBJECT >::EraseListNode ( OBJECT * )
protected

◆ Flag() [1/3]

G4FastListNode< G4Track > * G4FastList< G4Track >::Flag ( G4Track * __track)
protected

SPECIFIC TO TRACKS.

◆ Flag() [2/3]

G4FastListNode< G4Track > * G4FastList< G4Track >::Flag ( G4Track * __track)
protected

SPECIFIC TO TRACKS.

Definition at line 99 of file G4TrackList.cc.

100{
101 G4IT* __iTrack = GetIT(__track);
102 G4FastListNode<G4Track>* __trackListNode = __iTrack->GetListNode();
103
104 if (__trackListNode != nullptr)
105 {
106 // Suggestion move the node to this list
107 if (__trackListNode->fAttachedToList)
108 {
109 G4ExceptionDescription exceptionDescription;
110 exceptionDescription << "This track " << __iTrack->GetName();
111 exceptionDescription << " is already attached to a TrackList ";
112 G4Exception("G4FastList<OBJECT>::Flag", "G4TrackList001",
114 exceptionDescription);
115 }
116 } else
117 {
118 __trackListNode = new G4FastListNode<G4Track>(__track);
119 __iTrack->SetListNode(__trackListNode);
120 }
121
122 __trackListNode->fAttachedToList = true;
123 __trackListNode->fListRef = fListRef;
124 return __trackListNode;
125}
G4shared_ptr< _ListRef< G4FastList< OBJECT > > > fListRef
void SetListNode(G4TrackListNode *node)
Definition G4IT.hh:152

◆ Flag() [3/3]

template<class OBJECT >
G4FastListNode< OBJECT > * G4FastList< OBJECT >::Flag ( OBJECT * )
protected

◆ GetList() [1/4]

template<class OBJECT >
static G4FastList< OBJECT > * G4FastList< OBJECT >::GetList ( G4FastListNode< OBJECT > * __trackListNode)
static

◆ GetList() [2/4]

G4FastList< G4Track > * G4FastList< G4Track >::GetList ( G4Track * __track)

SPECIFIC TO TRACKS.

◆ GetList() [3/4]

G4FastList< G4Track > * G4FastList< G4Track >::GetList ( G4Track * __track)

SPECIFIC TO TRACKS.

Definition at line 176 of file G4TrackList.cc.

177{
178 G4IT* __IT = GetIT(__track);
179 G4FastListNode<G4Track>* __trackListNode = __IT->GetListNode();
180
181 if(__trackListNode == nullptr) return nullptr;
182 if(__trackListNode->fListRef == nullptr) return nullptr;
183
184 return __trackListNode->fListRef->fpList;
185}

◆ GetList() [4/4]

template<class OBJECT >
static G4FastList< OBJECT > * G4FastList< OBJECT >::GetList ( OBJECT * )
static

◆ GetListNode()

template<class OBJECT >
G4FastListNode< G4FastList< OBJECT > > * G4FastList< OBJECT >::GetListNode ( )
inline

Definition at line 332 of file G4FastList.hh.

333 {
334 return fpNodeInManyLists;
335 }
G4FastListNode< G4FastList< OBJECT > > * fpNodeInManyLists

Referenced by PriorityList::PushToListOfSecondaries().

◆ GetNode() [1/3]

G4FastListNode< G4Track > * G4FastList< G4Track >::GetNode ( G4Track * __track)

SPECIFIC TO TRACKS.

◆ GetNode() [2/3]

G4FastListNode< G4Track > * G4FastList< G4Track >::GetNode ( G4Track * __track)

SPECIFIC TO TRACKS.

Definition at line 162 of file G4TrackList.cc.

163{
164 G4IT* __IT = GetIT(__track);
165 G4FastListNode<G4Track>* __trackListNode = __IT->GetListNode();
166 // TODO : complete the exception
167 if (__trackListNode == nullptr)
168 {
169 return nullptr;
170 }
171 return __trackListNode;
172}

◆ GetNode() [3/3]

template<class OBJECT >
static G4FastListNode< OBJECT > * G4FastList< OBJECT >::GetNode ( OBJECT * )
static

Complexity = constant

◆ Holds() [1/3]

bool G4FastList< G4Track >::Holds ( const G4Track * track) const

SPECIFIC TO TRACKS.

◆ Holds() [2/3]

bool G4FastList< G4Track >::Holds ( const G4Track * track) const

SPECIFIC TO TRACKS.

Definition at line 92 of file G4TrackList.cc.

93{
94 return (GetIT(track)->GetListNode()->fListRef->fpList == this);
95}
G4FastListNode< G4FastList< OBJECT > > * GetListNode()

◆ Holds() [3/3]

template<class OBJECT >
bool G4FastList< OBJECT >::Holds ( const OBJECT * ) const

return an iterator that contains an empty node use for boundary checking only

◆ Hook()

template<class OBJECT >
void G4FastList< OBJECT >::Hook ( G4FastListNode< OBJECT > * ,
G4FastListNode< OBJECT > *  )
protected

◆ insert()

template<class OBJECT >
iterator G4FastList< OBJECT >::insert ( iterator ,
OBJECT *  )

◆ Pop()

template<class OBJECT >
static void G4FastList< OBJECT >::Pop ( OBJECT * )
static

◆ pop() [1/3]

template<class OBJECT >
iterator G4FastList< OBJECT >::pop ( G4FastListNode< OBJECT > * )

◆ pop() [2/3]

template<class OBJECT >
iterator G4FastList< OBJECT >::pop ( iterator __first,
iterator __last )

◆ pop() [3/3]

template<class OBJECT >
iterator G4FastList< OBJECT >::pop ( OBJECT * )

◆ pop_back()

template<class OBJECT >
OBJECT * G4FastList< OBJECT >::pop_back ( )

◆ push_back()

◆ push_front()

template<class OBJECT >
void G4FastList< OBJECT >::push_front ( OBJECT * __track)
inline

◆ remove()

template<class OBJECT >
void G4FastList< OBJECT >::remove ( OBJECT * )

◆ RemoveWatcher()

template<class OBJECT >
void G4FastList< OBJECT >::RemoveWatcher ( Watcher * watcher)
inline

Definition at line 342 of file G4FastList.hh.

343 {
344 auto it = fWatchers.find(watcher);
345 if(it == fWatchers.end()) return; //TODO: exception?
346 fWatchers.erase(it);
347 }

Referenced by G4ManyFastLists< OBJECT >::Remove(), and G4FastList< OBJECT >::Watcher::StopWatching().

◆ SetListNode()

template<class OBJECT >
void G4FastList< OBJECT >::SetListNode ( G4FastListNode< G4FastList< OBJECT > > * __node)
inline

Definition at line 327 of file G4FastList.hh.

328 {
329 fpNodeInManyLists = __node;
330 }

◆ SetNode()

template<class OBJECT >
static void G4FastList< OBJECT >::SetNode ( OBJECT * __obj,
G4FastListNode< OBJECT > * __node )
static

◆ size()

template<class OBJECT >
G4int G4FastList< OBJECT >::size ( ) const
inline

Definition at line 356 of file G4FastList.hh.

357 {
358 return fNbObjects;
359 }

Referenced by PriorityList::GetNTracks(), and G4ITTrackHolder::KillTracks().

◆ transferTo()

template<class OBJECT >
void G4FastList< OBJECT >::transferTo ( G4FastList< OBJECT > * )

◆ Unflag() [1/2]

template<class OBJECT >
void G4FastList< OBJECT >::Unflag ( G4FastListNode< OBJECT > * __trackListNode)
protected

◆ Unflag() [2/2]

template<class OBJECT >
G4FastListNode< OBJECT > * G4FastList< OBJECT >::Unflag ( OBJECT * )
protected

◆ Unhook()

template<class OBJECT >
void G4FastList< OBJECT >::Unhook ( G4FastListNode< OBJECT > * )
protected

Member Data Documentation

◆ fBoundary

template<class OBJECT >
G4FastListNode<OBJECT> G4FastList< OBJECT >::fBoundary
protected

Definition at line 225 of file G4FastList.hh.

Referenced by G4FastList< OBJECT >::back().

◆ fListRef

template<class OBJECT >
G4shared_ptr<_ListRef<G4FastList<OBJECT> > > G4FastList< OBJECT >::fListRef
protected

Definition at line 223 of file G4FastList.hh.

◆ fNbObjects

template<class OBJECT >
G4int G4FastList< OBJECT >::fNbObjects
protected

Definition at line 220 of file G4FastList.hh.

Referenced by G4FastList< OBJECT >::back(), and G4FastList< OBJECT >::size().

◆ fpNodeInManyLists

template<class OBJECT >
G4FastListNode<G4FastList<OBJECT> >* G4FastList< OBJECT >::fpNodeInManyLists
protected

◆ fWatchers

template<class OBJECT >
WatcherSet G4FastList< OBJECT >::fWatchers
protected

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