if(!tracks.count(*i))
pending.insert(*i);
+ if(tracks.empty())
+ {
+ set<Track *>::iterator i = pending.begin();
+ tracks.insert(*i);
+ pending.erase(i);
+ }
+
while(!pending.empty())
{
RouteValidityMask valid = ROUTE_INVALID;
- for(set<Track *>::const_iterator i=pending.begin(); i!=pending.end(); ++i)
- if(tracks.empty() || (valid=check_validity(**i))==ROUTE_VALID)
+ for(set<Track *>::iterator i=pending.begin(); i!=pending.end(); ++i)
+ if((valid=check_validity(**i))==ROUTE_VALID)
{
tracks.insert(*i);
- pending.erase(*i);
+ pending.erase(i);
break;
}