Are there any open source C libraries with common data structures? [closed]

Solution 1:

BSD queue.h has:

  • SLIST = singly linked list
  • LIST = doubly linked list
  • SIMPLEQ = singly linked queue
  • TAILQ = doubly linked queue

BSD tree.h has:

  • RB - red-black tree
  • SPLAY - splay tree

See the queue(3) and tree(3) man pages for details. I really like them because they are pure C macros without dependencies (not even libc). Plus with the BSD license you don't have to worry about any company restrictions w/ GPL.

Solution 2:

Gnome provides an excellent library for this, called Glib, with many useful data structures and other utilities as well.

Solution 3:

gnulib, the gnu portability library.

It's distributed as source code. This list is from its module list, which includes a TON of other things. One interesting one is "c-stack: Stack overflow handling, causing program exit."

  • list
  • array-list
  • carray-list
  • linked-list
  • avltree-list
  • rbtree-list
  • linkedhash-list
  • avltreehash-list
  • rbtreehash-list
  • sublist ( Sequential list data type backed by another list. )
  • oset (Abstract ordered set.)
  • array-oset
  • avltree-oset
  • rbtree-oset