3 ms·
I’d heavily bet against std::list having any kind of “extra capacity” logic, as it would have to be some kind of free list of Node types — best leave that to th
by dundarious 4y ago
I’d heavily bet against std::list having any kind of “extra capacity” logic, as it would have to be some kind of free list of Node types — best leave that to the general purpose allocator.
I think the list vs vector comparison is fair, as most people are taught to “just use the standard library, don’t be a hero, don’t commit a NIH crime”. I have done this myself at times, but in fairness, mostly when discussing adaptations of existing code, where there were bigger structural issues. And it cannot be repeated enough, that vector is far better than list, even at prepends or random insertions, for a surprisingly large number of elements (it was at least thousands of int32-s when I checked it about a decade ago). Typically the justification for a list is that the workload is prepend/random insert heavy, but in my experience there is more often than not a bound on the size that strongly favors vector.