Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

You have 10 seconds to implement std::vector in plain C

Name: Anonymous 2016-07-20 3:56

Must support:

* Adding elements
* Regrowing

Name: Cudder !cXCudderUE 2017-01-06 11:33

>>59
The main problem with abstractions like vectors is that it makes programmers forget (or ever learn) about resizing, and doing so can be slow since it involves copying all the elements. Thus you end up with code that despite knowing the final length, appends elements to a vector individually, possibly causing resizes, instead of sizing and allocating once and then reading all the elements in. Having to think about realloc() means you're more likely to write your code such that you can avoid it, rather than just doing v.push_back(e); all the time.

I see the latter (anti-)pattern in code a lot. It's disgusting.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List