Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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

[2] https://troydhanson.github.io/uthash/



Also there is the header-only khash.h [3], complete with benchmarks:

https://attractivechaos.wordpress.com/2008/08/28/comparison-...

(Also provides kbtree.h, ksort.h, kstream.h, kvec.h)

[3] 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


Definitely look into the Linux kernel data structures. Container_of is a fantastic way to do data structures in C.


Also, BSD tree.h for red-black trees and splay trees http://bxr.su/OpenBSD/sys/sys/tree.h


I 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.


A bit of ongoing work from me. Trying to make wiring C programs fast and painless.

https://github.com/mgrosvenor/libchaste


Have a look for Phong Vo's CDT - container data type - library.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: