Workhorse classes

What are your go-to data structures/classes that you use to solve the following problems?

* A buffer to be passed to a C interface.
* An ASCII string.
* An international string.
* A simple list of things.
* A variable set.
* A constant set.
* An associative array.
* A thread-safe queue (single producer, single consumer).
* A lock-free queue (single producer, single consumer).
* vector (and then pass the address of the first element)
* string
* QString
* vector
* set
* set
* map or unordered_map
* queue with a mutex
* never needed one

I'd have to have a good reason to get any more fancy than this. Sometimes there is a good reason, but these are my defaults.
Which queue? std::queue or std::deque?
I started to say use string for the buffer but I think of 'buffers' as bytes. Vector is probably the better pick generally.



Last edited on
* A buffer to be passed to a C interface.
std::vector
* An ASCII string.
std::string
* An international string.
std::string (std::strings hold UTF-8 data by default)
* A simple list of things.
std::vector
* A variable set.
std::unordered_set (unless you can get away with std::vector)
* A constant set.
std::unordered_set (unless you can get away with std::vector)
* An associative array.
std::unordered_map
* A thread-safe queue (single producer, single consumer).
tbb::concurrent_queue (technically MPMC, I don't know of a popular SPSC. I use an in-house one)
* A lock-free queue (single producer, single consumer).
boost::lockfree::spsc_queue (I use an in-house one)
Last edited on
Topic archived. No new replies allowed.