Choosing a STL container with uniqueness and which keeps insertion ordering

后端 未结 8 1986

I am unable to decide which STL container to use in the following case:

  1. I want to preserve the order of insertion of the elements
  2. The elements in the
8条回答
  •  野的像风
    2021-01-18 01:21

    If you already have boost installed, I like that option. Otherwise, why not just use a list or vector and add a check (find(k) == std::npos) on insertion? I suppose it could get kind of slow on a really, reallly large list, but for most cases it would work just fine.

提交回复
热议问题