9 UnitCollection::UnitListNode::UnitListNode(
Unit *unit ) : unit( unit )
15 UnitCollection::UnitListNode::UnitListNode(
Unit *unit, UnitListNode *
next ) : unit( unit )
22 UnitCollection::UnitListNode::~UnitListNode()
29 void UnitCollection::destr()
34 u->next = u->next->next;
44 static UnitListNode cat( NULL, NULL );
45 static UnitListNode dog( NULL, &cat );
46 static bool cachunk =
true;
50 static std::vector< UnitCollection::UnitListNode* >dogpile;
55 dogpile.push_back( node );
61 static std::vector< UnitCollection::UnitListNode* >bakdogpile;
62 std::vector< UnitCollection::UnitListNode* > *dogpile = (std::vector< UnitCollection::UnitListNode* >*)
PushUnusedNode(
64 bakdogpile.swap( *dogpile );
65 while ( !dogpile->empty() ) {
66 delete dogpile->back();
72 if (pos->next->unit) {
73 UnitListNode *tmp = pos->next->next;
84 while ( ( tmp = iter->current() ) ) {
86 n->next =
new UnitListNode( tmp, n->next );
93 while (n->next->unit != NULL)
96 while ( ( tmp = iter->current() ) ) {
97 n->next =
new UnitListNode( tmp, n->next );
105 while (n->next->unit != NULL)
107 n->next =
new UnitListNode( unit, n->next );
109 void UnitCollection::UnitListNode::PostInsert(
Unit *unit )
111 if (next->unit != NULL)
112 next->next =
new UnitListNode( unit, next->next );
114 next =
new UnitListNode( unit, next );
118 pos->PostInsert( unit );
122 pos->PostInsert( unit );
124 void UnitCollection::UnitListNode::Remove()
127 UnitListNode *tmp = next->next;
145 void UnitCollection::ConstIterator::GetNextValidUnit()
147 while (pos->next->unit ? pos->next->unit->Killed() :
false)
154 printf(
"warning could cause problems with concurrent lists. Make sure no one is traversing gotten list" );
159 const UnitListNode *n = uc.u;
173 const UnitListNode *n = uc.u;
185 if (
empty() )
return false;
187 while ( it.notDone() ) {
188 if (it.current() == unit)
200 if (
empty() )
return false;
202 while ( it.notDone() ) {
203 if (it.current() == unit)
204 it.remove(), res =
true;