3 #if defined (USE_OLD_COLLECTION)
5 #elif defined (USE_STL_COLLECTION)
43 for (it = orig->u.begin(); it != col->u.end(); ++it)
57 if ( col && it != col->u.end() )
63 if ( col && it != col->u.end() ) {
72 col->insert( it, unit );
77 list< Unit* >::iterator tmp = it;
78 if ( col && unit && it != col->u.end() ) {
80 col->insert( tmp, unit );
86 if ( !col || it == col->u.end() )
return;
87 if ( (*it) != NULL && (*it)->Killed() )
91 while ( it != col->u.end() ) {
94 else if ( (*it)->Killed() )
104 if ( !col || it == col->u.end() )
129 for (it = orig->u.begin(); it != col->u.end(); ++it)
140 if ( col && it != col->u.end() )
147 if ( !col || it == col->u.end() )
return;
149 while ( it != col->u.end() ) {
152 else if ( (*it)->Killed() )
178 activeIters.reserve( 20 );
183 list< Unit* >::const_iterator in = uc.u.begin();
184 while ( in != uc.u.end() ) {
193 for (list< Unit* >::iterator it = u.begin(); it != u.end(); ++it)
197 u.push_front( unit );
205 u.push_front( unit );
213 list< Unit* >::iterator tmpI = u.begin();
214 while ( (tmp = **it) ) {
216 u.insert( tmpI, tmp );
234 while ( (tmp = **it) ) {
245 temp = u.insert( temp, unit );
252 if ( !activeIters.empty() ) {
253 fprintf(stderr,
"WARNING! Attempting to clear a collection with active iterators!\n" );
257 for (list< Unit* >::iterator it = u.begin(); it != u.end(); ++it) {
264 void UnitCollection::destr()
266 for (list< Unit* >::iterator it = u.begin(); it != u.end(); ++it)
271 for (vector< un_iter* >::iterator t = activeIters.begin(); t != activeIters.end(); ++t)
277 if (u.empty() || !unit)
279 for (list< Unit* >::const_iterator it = u.begin(); it != u.end(); ++it)
280 if ( (*it) == unit && !(*it)->
Killed() )
292 if (activeIters.size() > 3) {
293 removedIters.push_back( it2 );
303 if (activeIters.size() > 1)
304 for (vector<UnitCollection::UnitIterator*>::size_type
i = 0;
i < activeIters.size(); ++
i)
305 if (activeIters[
i]->it == it2) {
306 removedIters.push_back( it2 );
316 it2 = u.erase( it2 );
322 if (u.empty() || !unit)
324 for (list< Unit* >::iterator it = u.begin(); it != u.end();) {
325 if ( (*it) == unit ) {
338 list< Unit* >::const_iterator in = uc.u.begin();
339 while ( in != uc.u.end() ) {
346 inline void UnitCollection::reg(
un_iter *iter )
348 activeIters.push_back( iter );
351 inline void UnitCollection::unreg(
un_iter *iter )
353 for (vector< un_iter* >::iterator t = activeIters.begin(); t != activeIters.end(); ++t)
354 if ( (*t) == iter ) {
355 activeIters.erase( t );
358 if ( activeIters.empty() || ( activeIters.size() == 1 && ( activeIters[0]->it == u.end() || ( *(activeIters[0]->it) ) ) ) )
359 while ( !removedIters.empty() ) {
360 u.erase( removedIters.back() );
361 removedIters.pop_back();
367 #endif //USE_STL_COLLECTION