eteran / c-vector

A dynamic array implementation in C similar to the one found in standard C++

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature suggestion: Shrink arrays

julianhartmer opened this issue · comments

What do you think about automatic shrinking of c-vectors? Currently, the vector capacity doubles when capacity == size. How about cutting the vector capacity in half when the (size >> 2) < capacity? This way, the capacity is cut in half when only a fourth of the capacity is used. I could make this feature optional by enabling it when CVECTOR_SHRINK is defined. What are your thoughts?

I'm open to it, especially if controlled by a macro so it's opt in. I'd also be even more in favor of a cvector_shrink_to_fit macro of some kind that would resize the vector to be an exact fit when the user wants it so.