Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ITBox Class Reference

#include <G4ITBox.hh>

Public Member Functions

 G4ITBox ()
 
 ~G4ITBox ()
 
void ResetStack ()
 
void Push (G4IT *)
 
void Extract (G4IT *)
 
G4ITFindIT (const G4Track &)
 
const G4ITFindIT (const G4Track &) const
 
void TransferTo (G4ITBox *)
 
G4bool Empty () const
 
G4int GetNTrack () const
 
G4ITGetFirstIT ()
 
G4ITGetLastIT ()
 
const G4ITGetFirstIT () const
 
const G4ITGetLastIT () const
 
void SetNextBox (G4ITBox *box)
 
G4ITBoxGetNextBox ()
 
const G4ITBoxGetNextBox () const
 
void SetPreviousBox (G4ITBox *box)
 
G4ITBoxGetPreviousBox ()
 
const G4ITBoxGetPreviousBox () const
 

Detailed Description

G4ITBox behaves just like a stack for G4IT. You can search for specific tracks. Each G4IT knows to which G4ITBox it belongs and its corresponding node. This makes the deletion of an element very fast. The drawback is that a G4IT can only belong to one G4ITBox. If you are not looking for this feature, please use std::list.

Definition at line 60 of file G4ITBox.hh.

Constructor & Destructor Documentation

◆ G4ITBox()

G4ITBox::G4ITBox ( )

Definition at line 37 of file G4ITBox.cc.

37 : fNbIT(0), fpFirstIT(0), fpLastIT(0), fpPreviousBox(0), fpNextBox(0)
38{;}

◆ ~G4ITBox()

G4ITBox::~G4ITBox ( )

Definition at line 40 of file G4ITBox.cc.

41{
42 if( fNbIT != 0 )
43 {
44 G4IT * aIT = fpFirstIT;
45 G4IT * nextIT;
46
47 while( aIT != 0 )
48 {
49 nextIT = aIT->GetNext();
50 delete aIT;
51 aIT = nextIT;
52 }
53 }
54
55 if(fpPreviousBox) fpPreviousBox->SetNextBox(fpNextBox) ;
56 if(fpNextBox) fpNextBox->SetPreviousBox(fpPreviousBox);
57}
void SetPreviousBox(G4ITBox *box)
Definition: G4ITBox.hh:143
void SetNextBox(G4ITBox *box)
Definition: G4ITBox.hh:133
Definition: G4IT.hh:88
G4IT * GetNext()
Definition: G4IT.hh:208

Member Function Documentation

◆ Empty()

G4bool G4ITBox::Empty ( ) const
inline

Definition at line 106 of file G4ITBox.hh.

107{
108 return (fNbIT <= 0);
109}

◆ Extract()

void G4ITBox::Extract ( G4IT aStackedIT)

Definition at line 86 of file G4ITBox.cc.

87{
88 if( aStackedIT == fpFirstIT )
89 {
90 fpFirstIT = aStackedIT->GetNext();
91 }
92 else if( aStackedIT == fpLastIT )
93 {
94 fpLastIT = aStackedIT->GetPrevious();
95
96 }
97
98 if( aStackedIT->GetNext())
99 aStackedIT->GetNext()->SetPrevious(aStackedIT->GetPrevious());
100 if( aStackedIT->GetPrevious())
101 aStackedIT->GetPrevious()->SetNext(aStackedIT->GetNext());
102
103 aStackedIT->SetNext(0);
104 aStackedIT->SetPrevious(0);
105 aStackedIT->SetITBox(0);
106 fNbIT--;
107}
void SetITBox(G4ITBox *)
Definition: G4IT.hh:188
void SetPrevious(G4IT *)
Definition: G4IT.hh:193
G4IT * GetPrevious()
Definition: G4IT.hh:203
void SetNext(G4IT *)
Definition: G4IT.hh:198

Referenced by G4IT::TakeOutBox(), and TransferTo().

◆ FindIT() [1/2]

G4IT * G4ITBox::FindIT ( const G4Track track)

The FindIT methods are used for check only. Those methods are not effective due to the linear search. It is better to use GetIT(track) in order to retrieve the IT and GetIT(track)->GetBox() in order to check which is the box pointer.

Definition at line 109 of file G4ITBox.cc.

110{
111 if( fNbIT == 0 ) return 0;
112
113 G4IT * temp = fpLastIT;
114 G4bool find = false;
115
116 while(find == false && temp != 0)
117 {
118 if(temp-> GetTrack() == &track)
119 {
120 find = true;
121 break;
122 }
123 temp = temp->GetPrevious();
124 }
125
126 return temp;
127}
bool G4bool
Definition: G4Types.hh:86

◆ FindIT() [2/2]

const G4IT * G4ITBox::FindIT ( const G4Track track) const

Definition at line 129 of file G4ITBox.cc.

130{
131 if( fNbIT == 0 ) return 0;
132
133 const G4IT * temp = fpLastIT;
134 G4bool find = false;
135
136 while(find == false && temp != 0)
137 {
138 if(temp-> GetTrack() == &track)
139 {
140 find = true;
141 break;
142 }
143 temp = temp->GetPrevious();
144 }
145
146 return temp;
147}

◆ GetFirstIT() [1/2]

G4IT * G4ITBox::GetFirstIT ( )
inline

Definition at line 115 of file G4ITBox.hh.

116{
117 return fpFirstIT;
118}

◆ GetFirstIT() [2/2]

const G4IT * G4ITBox::GetFirstIT ( ) const
inline

Definition at line 124 of file G4ITBox.hh.

125{
126 return fpFirstIT;
127}

◆ GetLastIT() [1/2]

G4IT * G4ITBox::GetLastIT ( )
inline

Definition at line 119 of file G4ITBox.hh.

120{
121 return fpLastIT;
122}

◆ GetLastIT() [2/2]

const G4IT * G4ITBox::GetLastIT ( ) const
inline

Definition at line 128 of file G4ITBox.hh.

129{
130 return fpLastIT;
131}

◆ GetNextBox() [1/2]

G4ITBox * G4ITBox::GetNextBox ( )
inline

Definition at line 138 of file G4ITBox.hh.

139{
140 return fpNextBox;
141}

◆ GetNextBox() [2/2]

const G4ITBox * G4ITBox::GetNextBox ( ) const
inline

◆ GetNTrack()

G4int G4ITBox::GetNTrack ( ) const
inline

Definition at line 111 of file G4ITBox.hh.

112{
113 return fNbIT;
114}

◆ GetPreviousBox() [1/2]

G4ITBox * G4ITBox::GetPreviousBox ( )
inline

Definition at line 148 of file G4ITBox.hh.

149{
150 return fpPreviousBox;
151}

◆ GetPreviousBox() [2/2]

const G4ITBox * G4ITBox::GetPreviousBox ( ) const
inline

◆ Push()

void G4ITBox::Push ( G4IT aIT)

Definition at line 69 of file G4ITBox.cc.

70{
71 if( fNbIT == 0 )
72 {
73 aIT->SetPrevious( 0 );
74 fpFirstIT = aIT;
75 }
76 else
77 {
78 fpLastIT->SetNext( aIT );
79 aIT->SetPrevious( fpLastIT );
80 }
81 fpLastIT = aIT;
82 fNbIT++;
83 aIT->SetITBox(this);
84}

Referenced by TransferTo().

◆ ResetStack()

void G4ITBox::ResetStack ( )

◆ SetNextBox()

void G4ITBox::SetNextBox ( G4ITBox box)
inline

Definition at line 133 of file G4ITBox.hh.

134{
135 fpNextBox = box;
136}

Referenced by ~G4ITBox().

◆ SetPreviousBox()

void G4ITBox::SetPreviousBox ( G4ITBox box)
inline

Definition at line 143 of file G4ITBox.hh.

144{
145 fpPreviousBox = box;
146}

Referenced by ~G4ITBox().

◆ TransferTo()

void G4ITBox::TransferTo ( G4ITBox aStack)

Definition at line 149 of file G4ITBox.cc.

150{
151 G4IT * ITToTransfer = fpFirstIT;
152 while(fNbIT)
153 {
154 Extract(ITToTransfer);
155 aStack->Push(ITToTransfer);
156 ITToTransfer = ITToTransfer->GetNext();
157 }
158}
void Extract(G4IT *)
Definition: G4ITBox.cc:86
void Push(G4IT *)
Definition: G4ITBox.cc:69

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