4 ms·
Since you never traverse the list, the order of elements obviously doesn't matter. In that case, you can just swap the element to remove with the last element.
by mihai_ionic 13y ago
Since you never traverse the list, the order of elements obviously doesn't matter. In that case, you can just swap the element to remove with the last element.
A vector will still give you better cache-locality and also amortize the number of allocations.
- rumcajz 13y agoYes, that's exaclty what ZeroMQ is doing. Then check how the code looks like. It's a mess. Intrusive containers deliver same performance characteristics and the code actually looks clean.
- alexchamberlain 13y agoAnd what stops you using an intrusive datastructure in C++?
- vidarh 13y agoNothing. But if he is going to write C in C++, then what is the point of writing C++? Especially sticking to C gives substantially increased flexibility in terms of language bindings, embedded usage etc. I've probably spent more years writing C++ code than C code, but I'm all with him on this - if what you need to do for whatever reason don't need/benefit all that much from C++ when accounting for all constraints, then choosing C as being the lowest common denominator between other languages is a very good choice for a library.