std::vector
sounds like a perfect fit. If you know in advance how many elements you get, use vector::reserve
or vector::resize
to not overallocate. Otherwise use vector::shrink_to_fit
after lots of insertions.
To speed up searches on the id
, sort the vector
on it and use a binary_search/lower_bound
.
If you have lots of strings with the same content, use a flyweight class. This can also substantially speed up string comparisons.
To search quickly on string members, get a vector
of iterators into your container and sort those or go for a boost::multi_index
.
A small calculation to back that up: assuming int
is 4 bytes, your strings average 20 letters, 30 000 elements, makes roughly 2 megabyte. Nothing to worry about.