39#if defined __cplusplus
44static int initialSizeOfList = 100, incrementalSizeOfList = 100;
45static int numberOfParticles = 0, sizeOfParticleSortedList = 0;
47static tpia_particle *particleList = NULL, *particleListEnd = NULL;
56 if( particle == NULL )
return( NULL );
77 for( i = 0, p = particleSortedList; i < numberOfParticles; i++, p++ ) {
78 if( *p == particle ) {
80 for( j = i; j < numberOfParticles; j++, p++ ) *p = p[1];
84 if( particle == particleListEnd ) particleListEnd = particle->
prior;
85 if( particle == particleList ) particleList = particle->
next;
115 int i, iCmp, min, mid, max, Z, A, m;
121 max = numberOfParticles;
122 while( min != max ) {
123 mid = ( min + max ) / 2;
124 iCmp = strcmp( name, particleSortedList[mid]->name );
125 if( iCmp == 0 )
return( particleSortedList[mid] );
128 if( mid == 0 ) max = 0; }
131 if( min > max ) min = max;
135 if( numberOfParticles > 0 ) {
136 iCmp = strcmp( name, particleSortedList[mid]->name );
137 if( iCmp == 0 )
return( particleSortedList[mid] );
138 if( ( iCmp < 0 ) && ( mid != 0 ) ) {
140 iCmp = strcmp( name, particleSortedList[mid]->name );
148 particle->
prior = NULL;
149 particle->
next = NULL;
157 if( sizeOfParticleSortedList < ( numberOfParticles + 1 ) ) {
158 if( sizeOfParticleSortedList == 0 ) {
159 sizeOfParticleSortedList = initialSizeOfList; }
161 sizeOfParticleSortedList += incrementalSizeOfList;
168 if( particleList == NULL ) {
170 particleListEnd = particleList = particle; }
173 particle->
prior = particleListEnd;
174 particleListEnd->
next = particle;
175 particleListEnd = particle;
178 if( ( mid != 0 ) || ( iCmp > 0 ) ) mid++;
179 for( i = numberOfParticles; i > mid; i-- ) particleSortedList[i] = particleSortedList[i-1];
180 particleSortedList[mid] = particle;
193 for( i = 0; i < numberOfParticles; i++ ) printf(
"%s\n", particleSortedList[i]->name );
197#if defined __cplusplus
int smr_isOk(statusMessageReporting *smr)
tpi_spectralID * spectralID
void * tpi_spectralID_free(statusMessageReporting *smr, tpi_spectralID *spectralID)
tpi_spectralID * tpi_spectralID_parse(statusMessageReporting *smr, char const *str, char **EOP)
double tpia_particleMass_AMU(statusMessageReporting *smr, const char *name)
int tpia_particle_release(statusMessageReporting *smr, tpia_particle *particle)
tpia_particle * tpia_particle_getInternalID(statusMessageReporting *smr, const char *const name)
tpia_particle * tpia_particle_free(statusMessageReporting *smr, tpia_particle *particle)
int tpia_particle_initialize(statusMessageReporting *smr, tpia_particle *particle)
int tpia_particle_printInternalSortedList(statusMessageReporting *smr)
int tpia_miscNameToZAm(statusMessageReporting *smr, const char *name, int *Z, int *A, int *m)
int tpia_particle_freeInternalList(statusMessageReporting *smr)
tpia_particle * tpia_particle_create(statusMessageReporting *smr)
void * xData_free(statusMessageReporting *smr, void *p)
#define xData_malloc2(smr, size, zero, forItem)
#define xData_realloc2(smr, old, size, forItem)