Cameron121341
Cameron121341

Reputation: 260

Best container for search and insert operation for few elements

I need to chose a container which will store only a few elements and also no duplicates. I will need later to search after the elements. I thought about set and unordered_set, which will be the best option ? The set will get its elements one by one.

Upvotes: 1

Views: 95

Answers (1)

Casey
Casey

Reputation: 10936

Just use std::vector. and std::find(...) before inserting. If it's already there, don't. If you need it to be sorted, call std::sort after successful insert.

Upvotes: 1

Related Questions