Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 61 of file G4ITBox.hh.

Constructor & Destructor Documentation

G4ITBox::G4ITBox ( )

Definition at line 38 of file G4ITBox.cc.

38  : fNbIT(0), fpFirstIT(0), fpLastIT(0), fpPreviousBox(0), fpNextBox(0)
39 {;}
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 
56  if(fpPreviousBox) fpPreviousBox->SetNextBox(fpNextBox) ;
57  if(fpNextBox) fpNextBox->SetPreviousBox(fpPreviousBox);
58 }
Definition: G4IT.hh:88
G4IT * GetNext()
Definition: G4IT.hh:209
void SetPreviousBox(G4ITBox *box)
Definition: G4ITBox.hh:144
void SetNextBox(G4ITBox *box)
Definition: G4ITBox.hh:134

Here is the call graph for this function:

Member Function Documentation

G4bool G4ITBox::Empty ( ) const
inline

Definition at line 107 of file G4ITBox.hh.

108 {
109  return (fNbIT <= 0);
110 }
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:199
void SetITBox(G4ITBox *)
Definition: G4IT.hh:189
G4IT * GetPrevious()
Definition: G4IT.hh:204
G4IT * GetNext()
Definition: G4IT.hh:209
void SetPrevious(G4IT *)
Definition: G4IT.hh:194

Here is the call graph for this function:

Here is the caller graph for this function:

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 }
Definition: G4IT.hh:88
G4IT * GetPrevious()
Definition: G4IT.hh:204
bool G4bool
Definition: G4Types.hh:79

Here is the call graph for this function:

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 }
Definition: G4IT.hh:88
G4IT * GetPrevious()
Definition: G4IT.hh:204
bool G4bool
Definition: G4Types.hh:79

Here is the call graph for this function:

G4IT * G4ITBox::GetFirstIT ( )
inline

Definition at line 116 of file G4ITBox.hh.

117 {
118  return fpFirstIT;
119 }
const G4IT * G4ITBox::GetFirstIT ( ) const
inline

Definition at line 125 of file G4ITBox.hh.

126 {
127  return fpFirstIT;
128 }
G4IT * G4ITBox::GetLastIT ( )
inline

Definition at line 120 of file G4ITBox.hh.

121 {
122  return fpLastIT;
123 }
const G4IT * G4ITBox::GetLastIT ( ) const
inline

Definition at line 129 of file G4ITBox.hh.

130 {
131  return fpLastIT;
132 }
G4ITBox * G4ITBox::GetNextBox ( )
inline

Definition at line 139 of file G4ITBox.hh.

140 {
141  return fpNextBox;
142 }
const G4ITBox* G4ITBox::GetNextBox ( ) const
inline
G4int G4ITBox::GetNTrack ( ) const
inline

Definition at line 112 of file G4ITBox.hh.

113 {
114  return fNbIT;
115 }
G4ITBox * G4ITBox::GetPreviousBox ( )
inline

Definition at line 149 of file G4ITBox.hh.

150 {
151  return fpPreviousBox;
152 }
const G4ITBox* G4ITBox::GetPreviousBox ( ) const
inline
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:199
void SetITBox(G4ITBox *)
Definition: G4IT.hh:189
void SetPrevious(G4IT *)
Definition: G4IT.hh:194

Here is the call graph for this function:

Here is the caller graph for this function:

void G4ITBox::ResetStack ( )
void G4ITBox::SetNextBox ( G4ITBox box)
inline

Definition at line 134 of file G4ITBox.hh.

135 {
136  fpNextBox = box;
137 }

Here is the caller graph for this function:

void G4ITBox::SetPreviousBox ( G4ITBox box)
inline

Definition at line 144 of file G4ITBox.hh.

145 {
146  fpPreviousBox = box;
147 }

Here is the caller graph for this function:

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 }
Definition: G4IT.hh:88
void Push(G4IT *)
Definition: G4ITBox.cc:70
G4IT * GetNext()
Definition: G4IT.hh:209
void Extract(G4IT *)
Definition: G4ITBox.cc:87

Here is the call graph for this function:


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