简单来说 先对vector sort。。再用 lower_bound( )和upper_bound( ) 利用二分查找加速查找

比如一个vector<string> aList;

std::sort(aList.begin(), aList.end());

 

vector<string>::const_iterator it = lower_bound(aList.begin(), aList.end(), sReq);
if (it == aList.end() || *it != sReq )
{

//查找失败处理

}

 

相关文章:

  • 2021-07-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-09
  • 2021-08-03
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-23
  • 2022-01-27
  • 2021-07-07
  • 2021-10-04
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案