3 ms·
I've heard of two possibilities (as a recommendation) for using data structures in C without having to develop them: - BSD queue.h offers linked lists, queues,
by fizixer 9y ago
I've heard of two possibilities (as a recommendation) for using data structures in C without having to develop them:
- BSD queue.h offers linked lists, queues, etc [1].
- UT-hash offers hash tables [2].
I've also read some people being frustrated with them, probably due to the quirky syntax/API. On the plus side (BSD at least) it's just a header file that you can download, include and start using.
[1] http://bxr.su/OpenBSD/sys/sys/queue.h http://bxr.su/OpenBSD/sys/sys/queue.h
[2] https://troydhanson.github.io/uthash/ https://troydhanson.github.io/uthash/
- dottrap 9y agoAlso there is the header-only khash.h [3], complete with benchmarks: https://attractivechaos.wordpress.com/2008/08/28/comparison-of-hash-table-libraries/ https://attractivechaos.wordpress.com/2008/08/28/comparison-... (Also provides kbtree.h, ksort.h, kstream.h, kvec.h) [3] https://attractivechaos.wordpress.com/programs/ https://attractivechaos.wordpress.com/programs/ Also there are the stb header-only libraries. There is a hash table implementation buried inside stb.h [4] https://github.com/nothings/stb https://github.com/nothings/stb
- nurettin 9y agoI think at this point if you aren't in a very constrained platform, it doesn't really make sense to use someone else's data structure implementations unless they at least support some kind of CPU parallelism. Preferably openmp or whatever suits the algorithm at hand.
- DSMan195276 9y agoDefinitely look into the Linux kernel data structures. Container_of is a fantastic way to do data structures in C.
- sigjuice 9y agoAlso, BSD tree.h for red-black trees and splay trees http://bxr.su/OpenBSD/sys/sys/tree.h http://bxr.su/OpenBSD/sys/sys/tree.h
- atrn 9y agoHave a look for Phong Vo's CDT - container data type - library.
- deadgrey19 9y agoA bit of ongoing work from me. Trying to make wiring C programs fast and painless. https://github.com/mgrosvenor/libchaste https://github.com/mgrosvenor/libchaste