The original implementation of kvec.h is quite old (the last modification is even 12 years before) and lacks a bunch of functionalities. So I made some improvements to the source code.
I added a statement to kv_resize so that it can correctly handle the changes of (v).n while resizing.
I added two macros kv_insert and kv_remove as dynamic operations on the vector. They are some basic operations adopted by STL in C++ and other implementations of vector.
The original kv_pop method didn't decrease the capability of the vector, which could cause memory waste in some cases. So I defined another macro called kv_p to address this problem. The macro kv_pop is kept unchanged for capability, and it can be used for better performance.
The original implementation of
kvec.h
is quite old (the last modification is even 12 years before) and lacks a bunch of functionalities. So I made some improvements to the source code.kv_resize
so that it can correctly handle the changes of(v).n
while resizing.kv_insert
andkv_remove
as dynamic operations on the vector. They are some basic operations adopted by STL in C++ and other implementations of vector.kv_pop
method didn't decrease the capability of the vector, which could cause memory waste in some cases. So I defined another macro calledkv_p
to address this problem. The macrokv_pop
is kept unchanged for capability, and it can be used for better performance.