40 #if defined __cplusplus
45 static G4ThreadLocal int initialSizeOfList = 100, incrementalSizeOfList = 100;
46 static G4ThreadLocal int numberOfParticles = 0, sizeOfParticleSortedList = 0;
57 if( particle == NULL )
return( NULL );
78 for( i = 0, p = particleSortedList; i < numberOfParticles; i++, p++ ) {
79 if( *p == particle ) {
81 for( j = i; j < numberOfParticles; j++, p++ ) *p = p[1];
85 if( particle == particleListEnd ) particleListEnd = particle->
prior;
116 int i, iCmp,
min, mid,
max,
Z, A,
m;
122 max = numberOfParticles;
123 while( min != max ) {
124 mid = ( min +
max ) / 2;
125 iCmp = strcmp( name, particleSortedList[mid]->name );
126 if( iCmp == 0 )
return( particleSortedList[mid] );
129 if( mid == 0 ) max = 0; }
132 if( min > max ) min =
max;
136 if( numberOfParticles > 0 ) {
137 iCmp = strcmp( name, particleSortedList[mid]->name );
138 if( iCmp == 0 )
return( particleSortedList[mid] );
139 if( ( iCmp < 0 ) && ( mid != 0 ) ) {
141 iCmp = strcmp( name, particleSortedList[mid]->name );
149 particle->
prior = NULL;
150 particle->
next = NULL;
158 if( sizeOfParticleSortedList < ( numberOfParticles + 1 ) ) {
159 if( sizeOfParticleSortedList == 0 ) {
160 sizeOfParticleSortedList = initialSizeOfList; }
162 sizeOfParticleSortedList += incrementalSizeOfList;
174 particle->
prior = particleListEnd;
175 particleListEnd->
next = particle;
176 particleListEnd = particle;
179 if( ( mid != 0 ) || ( iCmp > 0 ) ) mid++;
180 for( i = numberOfParticles; i > mid; i-- ) particleSortedList[i] = particleSortedList[i-1];
181 particleSortedList[mid] = particle;
194 for( i = 0; i < numberOfParticles; i++ )
printf(
"%s\n", particleSortedList[i]->
name );
198 #if defined __cplusplus
int tpia_particle_initialize(statusMessageReporting *smr, tpia_particle *particle)
tpi_spectralID * tpi_spectralID_parse(statusMessageReporting *smr, char const *str, char **EOP)
#define xData_malloc2(smr, size, zero, forItem)
int tpia_particle_release(statusMessageReporting *smr, tpia_particle *particle)
void * xData_free(statusMessageReporting *smr, void *p)
int tpia_miscNameToZAm(statusMessageReporting *smr, const char *name, int *Z, int *A, int *m)
tpi_spectralID * spectralID
tpia_particle * tpia_particle_free(statusMessageReporting *smr, tpia_particle *particle)
void * tpi_spectralID_free(statusMessageReporting *smr, tpi_spectralID *spectralID)
#define xData_realloc2(smr, old, size, forItem)
double tpia_particleMass_AMU(statusMessageReporting *smr, const char *name)
int tpia_particle_freeInternalList(statusMessageReporting *smr)
tpia_particle * tpia_particle_getInternalID(statusMessageReporting *smr, const char *const name)
int smr_isOk(statusMessageReporting *smr)
T max(const T t1, const T t2)
brief Return the largest of the two arguments
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
printf("%d Experimental points found\n", nlines)
tpia_particle * tpia_particle_create(statusMessageReporting *smr)
int tpia_particle_printInternalSortedList(statusMessageReporting *smr)