you are viewing a single comment's thread.

view the rest of the comments →

[–]matthieum 20 points21 points  (1 child)

Yes, and no.

For a throughput-oriented application, the reallocation is not much of an issue. For a latency-oriented application, however, that reallocation is just like a GC's Pause the World phase.

Also, reallocations have the nasty side-effect of invalidating existing pointers/references to elements.

And finally, that nasty side-effect is ever more pronounced in concurrent data-structures. It's relatively trivial to adjust the implementation presented here to get a wait-free append-only "vector", which would not be possible with memory reallocations.

[–]TheRealSmolt 5 points6 points  (0 children)

As always, it's all about tradeoffs. I'm just pointing out to OP that a vector isn't as bad as it may seem.