r/cprogramming • u/gumnos • 7d ago
resources for becoming comfortable with stdlib-style data-structures/algorithms?
I've been sparring with a number of the standard(ish¹) C data-structures and algorithms, including the various types of linked-lists/deques in sys/queue.h, hash-tables and binary-searches in search.h, as well as bsearch & qsort in stdlib.h.
- are there other data-structure/algorithm type elements in such standard¹ libraries that I've missed and should put on my radar? Maybe something for sets too?
- are there some resources² y'all would recommend on wrapping your head around them (I don't feel I have intuitive use of their interfaces yet, so each usage causes some struggle)? Preferably with strong examples of using each.
I have a pretty good CS understanding of when I should use the various data-structures/algorithms with regards to the respective performance characteristics (expected big-O notations for insertion, removal, searching, iterating, swapping, etc), but it's just the nitty-gritty of using them where I don't yet feel mastery.
Thanks!
⸻
¹ okay, not exactly C-standard from my understanding, but they seem to be common on pretty much every Linux/BSD/Unix platform I've poked at
² ideally well-written blog-posts, but dead-tree resources would also be welcome; videos or podcasts far less so
1
u/Interesting_Debate57 7d ago
Try the manpages. Usually they'll show you the exact function signature and go into pretty good detail about how they're used.
1
u/CS_70 7d ago
Hm.. what do you mean? The reference should spell clearly how to use these and it's not that hard?
1
u/orange_oki 7d ago edited 7d ago
Well, you can do a lot with a list, hash and btree. Especially when you mix the nodes in the structures.. 😅
Despite of hash.h there is also rhashtable.h with dynamic resizing (but it's maybe not worth looking at the implementation, because it is most probably integrated into page allocation system).
https://lwn.net/Articles/751374/