问题
I wonder if there is an alternative for the std::vector in C? I found this implementation but it seems to contain some issues with memory reallocation.
回答1:
While reading C Array vs. C++ Vector, I found an interesting implementation of a simple vector container in C, which also includes push/pop operations. It's worth reading it!
回答2:
You can give glib and its arrays (GArray
) a try.
glib is actively maintained, cross platform, open source (LGPLv2+), and it doesn't stop on arrays/vectors. You also have hash tables, linked lists, queues and many other data structures.
回答3:
If you focus is on mathematics you can work with GSL, there have a more bare bones math centric concept.
来源:https://stackoverflow.com/questions/4924485/stdvector-alternative-for-c