39 #if defined __cplusplus
44 static int initialSizeOfList = 100, incrementalSizeOfList = 100;
45 static int numberOfParticles = 0, sizeOfParticleSortedList = 0;
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;
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;
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