Which is the fastest STL container for find?

后端 未结 5 1219
慢半拍i
慢半拍i 2020-12-08 00:35

Alright as a preface I have a need to cache a relatively small subset of rarely modified data to avoid querying the database as frequently for performance reasons. This data

5条回答
  •  佛祖请我去吃肉
    2020-12-08 01:09

    A sorted vector using std::lower_bound can be just as fast as std::set if you're not updating very often; they're both O(log n). It's worth trying both to see which is better for your own situation.

提交回复
热议问题