48

What are good libraries for C with datastructures like vectors, deques, stacks, hashmaps, treemaps, sets, etc.? Plain C, please, and platform-independent.

Community
  • 1
  • 1
Michiel de Mare
  • 41,284
  • 28
  • 101
  • 134

5 Answers5

38

The Glib library used on the Gnome project may also be some use. Moreover it is pretty well tested.

IBM developer works has a good tutorial on its use: Manage C data using the GLib collections

user
  • 5,119
  • 7
  • 45
  • 62
Brendan
  • 18,163
  • 17
  • 79
  • 106
  • But see [this answer](http://stackoverflow.com/a/17448240/1593077): It seems glib assumes you never go out of memory, and if you do, it `abort()`s your program, which is a pretty rough constraint. – einpoklum Jul 03 '13 at 16:02
  • I tried it before, harder to use than stl(cumber some) and have no performance benefits compare to stl. – StereoMatching Nov 30 '13 at 08:42
13

As always, Google is your friend:

http://nixbit.com/cat/programming/libraries/c-generic-library/

specifically:

http://nixbit.com/cat/programming/libraries/generic-data-structures-library/

Stu
  • 15,285
  • 4
  • 39
  • 73
5

There's some stuff in the Apache Portable Runtime (APR) that I'd expect to be very solid.

jmah
  • 2,218
  • 14
  • 16
4

Maybe http://sglib.sourceforge.net/ if you want an easy to use, very fast, macro based library.

Flavius Suciu
  • 179
  • 1
  • 3
2

If hash tables, extensible strings and dynamic vector are enough for your needs, please have a look at the library I put toghether: http://code.google.com/p/c-libutl/.

I also would welcome any feedback!

Remo.D
  • 15,640
  • 6
  • 42
  • 72