请教 一段 C++ STL 程序运行速度慢的问题
下面的函数运行速度非常慢,哪些地方有问题呢?谢谢!// Find the address of the company with the given name.
string FindAddress( list<Company> companies, string name )
{
for( list<Company>::iterator i = companies.begin(); i != companies.end(); i++ )
{
if( *i == name )
{
return (*i).address;
}
}
return "";
}