Geant4-11
Public Member Functions | Private Member Functions | Private Attributes
G4ITBox Class Reference

#include <G4ITBox.hh>

Public Member Functions

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

Private Member Functions

const G4ITBoxoperator= (const G4ITBox &right)
 

Private Attributes

G4int fNbIT
 
G4ITfpFirstIT
 
G4ITfpLastIT
 
G4ITBoxfpNextBox
 
G4ITBoxfpPreviousBox
 

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.

38{;}
G4ITBox * fpPreviousBox
Definition: G4ITBox.hh:102
G4IT * fpLastIT
Definition: G4ITBox.hh:100
G4int fNbIT
Definition: G4ITBox.hh:98
G4ITBox * fpNextBox
Definition: G4ITBox.hh:103
G4IT * fpFirstIT
Definition: G4ITBox.hh:99

◆ ~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
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

References fNbIT, fpFirstIT, fpNextBox, fpPreviousBox, G4IT::GetNext(), SetNextBox(), and SetPreviousBox().

Member Function Documentation

◆ Empty()

G4bool G4ITBox::Empty ( ) const
inline

Definition at line 106 of file G4ITBox.hh.

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

References fNbIT.

◆ 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

References fNbIT, fpFirstIT, fpLastIT, G4IT::GetNext(), G4IT::GetPrevious(), G4IT::SetITBox(), G4IT::SetNext(), and G4IT::SetPrevious().

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

References fNbIT, fpLastIT, and G4IT::GetPrevious().

◆ 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}

References fNbIT, fpLastIT, and G4IT::GetPrevious().

◆ GetFirstIT() [1/2]

G4IT * G4ITBox::GetFirstIT ( )
inline

Definition at line 115 of file G4ITBox.hh.

116{
117 return fpFirstIT;
118}

References fpFirstIT.

◆ GetFirstIT() [2/2]

const G4IT * G4ITBox::GetFirstIT ( ) const
inline

Definition at line 124 of file G4ITBox.hh.

125{
126 return fpFirstIT;
127}

References fpFirstIT.

◆ GetLastIT() [1/2]

G4IT * G4ITBox::GetLastIT ( )
inline

Definition at line 119 of file G4ITBox.hh.

120{
121 return fpLastIT;
122}

References fpLastIT.

◆ GetLastIT() [2/2]

const G4IT * G4ITBox::GetLastIT ( ) const
inline

Definition at line 128 of file G4ITBox.hh.

129{
130 return fpLastIT;
131}

References fpLastIT.

◆ GetNextBox() [1/2]

G4ITBox * G4ITBox::GetNextBox ( )
inline

Definition at line 138 of file G4ITBox.hh.

139{
140 return fpNextBox;
141}

References fpNextBox.

◆ 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}

References fNbIT.

◆ GetPreviousBox() [1/2]

G4ITBox * G4ITBox::GetPreviousBox ( )
inline

Definition at line 148 of file G4ITBox.hh.

149{
150 return fpPreviousBox;
151}

References fpPreviousBox.

◆ GetPreviousBox() [2/2]

const G4ITBox * G4ITBox::GetPreviousBox ( ) const
inline

◆ operator=()

const G4ITBox & G4ITBox::operator= ( const G4ITBox right)
private

Definition at line 59 of file G4ITBox.cc.

60{
61 fNbIT = right.fNbIT;
62 fpFirstIT = right.fpFirstIT;
63 fpLastIT = right.fpLastIT;
64 fpPreviousBox = 0;
65 fpNextBox = 0;
66 return *this;
67}

References fNbIT, fpFirstIT, fpLastIT, fpNextBox, and fpPreviousBox.

◆ 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}

References fNbIT, fpFirstIT, fpLastIT, G4IT::SetITBox(), G4IT::SetNext(), and G4IT::SetPrevious().

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}

References fpNextBox.

Referenced by ~G4ITBox().

◆ SetPreviousBox()

void G4ITBox::SetPreviousBox ( G4ITBox box)
inline

Definition at line 143 of file G4ITBox.hh.

144{
145 fpPreviousBox = box;
146}

References fpPreviousBox.

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

References Extract(), fNbIT, fpFirstIT, G4IT::GetNext(), and Push().

Field Documentation

◆ fNbIT

G4int G4ITBox::fNbIT
private

Definition at line 98 of file G4ITBox.hh.

Referenced by Empty(), Extract(), FindIT(), GetNTrack(), operator=(), Push(), TransferTo(), and ~G4ITBox().

◆ fpFirstIT

G4IT* G4ITBox::fpFirstIT
private

Definition at line 99 of file G4ITBox.hh.

Referenced by Extract(), GetFirstIT(), operator=(), Push(), TransferTo(), and ~G4ITBox().

◆ fpLastIT

G4IT* G4ITBox::fpLastIT
private

Definition at line 100 of file G4ITBox.hh.

Referenced by Extract(), FindIT(), GetLastIT(), operator=(), and Push().

◆ fpNextBox

G4ITBox* G4ITBox::fpNextBox
private

Definition at line 103 of file G4ITBox.hh.

Referenced by GetNextBox(), operator=(), SetNextBox(), and ~G4ITBox().

◆ fpPreviousBox

G4ITBox* G4ITBox::fpPreviousBox
private

Definition at line 102 of file G4ITBox.hh.

Referenced by GetPreviousBox(), operator=(), SetPreviousBox(), and ~G4ITBox().


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