Geant4  10.02.p03
G4ITBox Class Reference

#include <G4ITBox.hh>

Collaboration diagram for G4ITBox:

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
 

Private Member Functions

const G4ITBoxoperator= (const G4ITBox &right)
 

Private Attributes

G4int fNbIT
 
G4ITfpFirstIT
 
G4ITfpLastIT
 
G4ITBoxfpPreviousBox
 
G4ITBoxfpNextBox
 

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 61 of file G4ITBox.hh.

Constructor & Destructor Documentation

◆ G4ITBox()

G4ITBox::G4ITBox ( )

Definition at line 38 of file G4ITBox.cc.

38  : fNbIT(0), fpFirstIT(0), fpLastIT(0), fpPreviousBox(0), fpNextBox(0)
39 {;}
G4ITBox * fpPreviousBox
Definition: G4ITBox.hh:103
G4ITBox * fpNextBox
Definition: G4ITBox.hh:104
G4IT * fpFirstIT
Definition: G4ITBox.hh:100
G4IT * fpLastIT
Definition: G4ITBox.hh:101
G4int fNbIT
Definition: G4ITBox.hh:99

◆ ~G4ITBox()

G4ITBox::~G4ITBox ( )

Definition at line 41 of file G4ITBox.cc.

42 {
43  if( fNbIT != 0 )
44  {
45  G4IT * aIT = fpFirstIT;
46  G4IT * nextIT;
47 
48  while( aIT != 0 )
49  {
50  nextIT = aIT->GetNext();
51  delete aIT;
52  aIT = nextIT;
53  }
54  }
55 
58 }
G4ITBox * fpPreviousBox
Definition: G4ITBox.hh:103
G4ITBox * fpNextBox
Definition: G4ITBox.hh:104
G4IT * GetNext()
Definition: G4IT.hh:205
void SetPreviousBox(G4ITBox *box)
Definition: G4ITBox.hh:144
G4IT * fpFirstIT
Definition: G4ITBox.hh:100
void SetNextBox(G4ITBox *box)
Definition: G4ITBox.hh:134
{ Class description:
G4int fNbIT
Definition: G4ITBox.hh:99
Here is the call graph for this function:

Member Function Documentation

◆ Empty()

G4bool G4ITBox::Empty ( ) const
inline

Definition at line 107 of file G4ITBox.hh.

108 {
109  return (fNbIT <= 0);
110 }
G4int fNbIT
Definition: G4ITBox.hh:99

◆ Extract()

void G4ITBox::Extract ( G4IT aStackedIT)

Definition at line 87 of file G4ITBox.cc.

88 {
89  if( aStackedIT == fpFirstIT )
90  {
91  fpFirstIT = aStackedIT->GetNext();
92  }
93  else if( aStackedIT == fpLastIT )
94  {
95  fpLastIT = aStackedIT->GetPrevious();
96 
97  }
98 
99  if( aStackedIT->GetNext())
100  aStackedIT->GetNext()->SetPrevious(aStackedIT->GetPrevious());
101  if( aStackedIT->GetPrevious())
102  aStackedIT->GetPrevious()->SetNext(aStackedIT->GetNext());
103 
104  aStackedIT->SetNext(0);
105  aStackedIT->SetPrevious(0);
106  aStackedIT->SetITBox(0);
107  fNbIT--;
108 }
void SetNext(G4IT *)
Definition: G4IT.hh:195
void SetITBox(G4ITBox *)
Definition: G4IT.hh:185
G4IT * GetPrevious()
Definition: G4IT.hh:200
G4IT * GetNext()
Definition: G4IT.hh:205
G4IT * fpFirstIT
Definition: G4ITBox.hh:100
void SetPrevious(G4IT *)
Definition: G4IT.hh:190
G4IT * fpLastIT
Definition: G4ITBox.hh:101
G4int fNbIT
Definition: G4ITBox.hh:99
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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 110 of file G4ITBox.cc.

111 {
112  if( fNbIT == 0 ) return 0;
113 
114  G4IT * temp = fpLastIT;
115  G4bool find = false;
116 
117  while(find == false && temp != 0)
118  {
119  if(temp-> GetTrack() == &track)
120  {
121  find = true;
122  break;
123  }
124  temp = temp->GetPrevious();
125  }
126 
127  return temp;
128 }
G4IT * GetPrevious()
Definition: G4IT.hh:200
bool G4bool
Definition: G4Types.hh:79
G4IT * fpLastIT
Definition: G4ITBox.hh:101
{ Class description:
G4int fNbIT
Definition: G4ITBox.hh:99
Here is the call graph for this function:

◆ FindIT() [2/2]

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

Definition at line 130 of file G4ITBox.cc.

131 {
132  if( fNbIT == 0 ) return 0;
133 
134  const G4IT * temp = fpLastIT;
135  G4bool find = false;
136 
137  while(find == false && temp != 0)
138  {
139  if(temp-> GetTrack() == &track)
140  {
141  find = true;
142  break;
143  }
144  temp = temp->GetPrevious();
145  }
146 
147  return temp;
148 }
G4IT * GetPrevious()
Definition: G4IT.hh:200
bool G4bool
Definition: G4Types.hh:79
G4IT * fpLastIT
Definition: G4ITBox.hh:101
{ Class description:
G4int fNbIT
Definition: G4ITBox.hh:99
Here is the call graph for this function:

◆ GetFirstIT() [1/2]

G4IT * G4ITBox::GetFirstIT ( )
inline

Definition at line 116 of file G4ITBox.hh.

117 {
118  return fpFirstIT;
119 }
G4IT * fpFirstIT
Definition: G4ITBox.hh:100

◆ GetFirstIT() [2/2]

const G4IT * G4ITBox::GetFirstIT ( ) const
inline

Definition at line 125 of file G4ITBox.hh.

126 {
127  return fpFirstIT;
128 }
G4IT * fpFirstIT
Definition: G4ITBox.hh:100

◆ GetLastIT() [1/2]

G4IT * G4ITBox::GetLastIT ( )
inline

Definition at line 120 of file G4ITBox.hh.

121 {
122  return fpLastIT;
123 }
G4IT * fpLastIT
Definition: G4ITBox.hh:101

◆ GetLastIT() [2/2]

const G4IT * G4ITBox::GetLastIT ( ) const
inline

Definition at line 129 of file G4ITBox.hh.

130 {
131  return fpLastIT;
132 }
G4IT * fpLastIT
Definition: G4ITBox.hh:101

◆ GetNextBox() [1/2]

G4ITBox * G4ITBox::GetNextBox ( )
inline

Definition at line 139 of file G4ITBox.hh.

140 {
141  return fpNextBox;
142 }
G4ITBox * fpNextBox
Definition: G4ITBox.hh:104

◆ GetNextBox() [2/2]

const G4ITBox* G4ITBox::GetNextBox ( ) const
inline

◆ GetNTrack()

G4int G4ITBox::GetNTrack ( ) const
inline

Definition at line 112 of file G4ITBox.hh.

113 {
114  return fNbIT;
115 }
G4int fNbIT
Definition: G4ITBox.hh:99

◆ GetPreviousBox() [1/2]

G4ITBox * G4ITBox::GetPreviousBox ( )
inline

Definition at line 149 of file G4ITBox.hh.

150 {
151  return fpPreviousBox;
152 }
G4ITBox * fpPreviousBox
Definition: G4ITBox.hh:103

◆ GetPreviousBox() [2/2]

const G4ITBox* G4ITBox::GetPreviousBox ( ) const
inline

◆ operator=()

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

Definition at line 60 of file G4ITBox.cc.

61 {
62  fNbIT = right.fNbIT;
63  fpFirstIT = right.fpFirstIT;
64  fpLastIT = right.fpLastIT;
65  fpPreviousBox = 0;
66  fpNextBox = 0;
67  return *this;
68 }
G4ITBox * fpPreviousBox
Definition: G4ITBox.hh:103
G4ITBox * fpNextBox
Definition: G4ITBox.hh:104
G4IT * fpFirstIT
Definition: G4ITBox.hh:100
G4IT * fpLastIT
Definition: G4ITBox.hh:101
G4int fNbIT
Definition: G4ITBox.hh:99

◆ Push()

void G4ITBox::Push ( G4IT aIT)

Definition at line 70 of file G4ITBox.cc.

71 {
72  if( fNbIT == 0 )
73  {
74  aIT->SetPrevious( 0 );
75  fpFirstIT = aIT;
76  }
77  else
78  {
79  fpLastIT->SetNext( aIT );
80  aIT->SetPrevious( fpLastIT );
81  }
82  fpLastIT = aIT;
83  fNbIT++;
84  aIT->SetITBox(this);
85 }
void SetNext(G4IT *)
Definition: G4IT.hh:195
void SetITBox(G4ITBox *)
Definition: G4IT.hh:185
G4IT * fpFirstIT
Definition: G4ITBox.hh:100
void SetPrevious(G4IT *)
Definition: G4IT.hh:190
G4IT * fpLastIT
Definition: G4ITBox.hh:101
G4int fNbIT
Definition: G4ITBox.hh:99
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ResetStack()

void G4ITBox::ResetStack ( )

◆ SetNextBox()

void G4ITBox::SetNextBox ( G4ITBox box)
inline

Definition at line 134 of file G4ITBox.hh.

135 {
136  fpNextBox = box;
137 }
G4ITBox * fpNextBox
Definition: G4ITBox.hh:104
Here is the caller graph for this function:

◆ SetPreviousBox()

void G4ITBox::SetPreviousBox ( G4ITBox box)
inline

Definition at line 144 of file G4ITBox.hh.

145 {
146  fpPreviousBox = box;
147 }
G4ITBox * fpPreviousBox
Definition: G4ITBox.hh:103
Here is the caller graph for this function:

◆ TransferTo()

void G4ITBox::TransferTo ( G4ITBox aStack)

Definition at line 150 of file G4ITBox.cc.

151 {
152  G4IT * ITToTransfer = fpFirstIT;
153  while(fNbIT)
154  {
155  Extract(ITToTransfer);
156  aStack->Push(ITToTransfer);
157  ITToTransfer = ITToTransfer->GetNext();
158  }
159 }
void Push(G4IT *)
Definition: G4ITBox.cc:70
G4IT * GetNext()
Definition: G4IT.hh:205
G4IT * fpFirstIT
Definition: G4ITBox.hh:100
{ Class description:
void Extract(G4IT *)
Definition: G4ITBox.cc:87
G4int fNbIT
Definition: G4ITBox.hh:99
Here is the call graph for this function:

Member Data Documentation

◆ fNbIT

G4int G4ITBox::fNbIT
private

Definition at line 99 of file G4ITBox.hh.

◆ fpFirstIT

G4IT* G4ITBox::fpFirstIT
private

Definition at line 100 of file G4ITBox.hh.

◆ fpLastIT

G4IT* G4ITBox::fpLastIT
private

Definition at line 101 of file G4ITBox.hh.

◆ fpNextBox

G4ITBox* G4ITBox::fpNextBox
private

Definition at line 104 of file G4ITBox.hh.

◆ fpPreviousBox

G4ITBox* G4ITBox::fpPreviousBox
private

Definition at line 103 of file G4ITBox.hh.


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