Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any library like STL (vector, map...) in C? [duplicate]

Tags:

c++

c

stl

Possible Duplicates:
Container Class / Library for C
Is there a good collection library for C-language?

In C++, you have a very useful Standard Template Library (STL) which has structures like vector, map, set...

If I am using plain C, is there any library provide similar structures/functions?

Thanks!

like image 451
user504136 Avatar asked Nov 30 '10 03:11

user504136


People also ask

Is there a vector library in C?

C Vector Library A simple vector library for C. This libary's vectors work in a similar manner to C++ vectors: they can store any type, their elements can be accessed via the [] operator, and elements may be added or removed with simple library calls. Note: the vector type is just an alias for void* defined in vec.

How do I copy a map to vector?

To convert a map to a vector of key-value pairs, the range should be iterators at the beginning and end of the given map, and the operation should be push_back() to insert each entry into the vector.

Which is faster vector or map?

Firstly, finding an item in a very small vector can easily be faster than the same thing in a map, because all the memory in a vector is always contiguous (and so plays more nicely with computers' caches and such things), and the number of comparisons needed to find something in a vector might be about the same as for ...

Can we use vector as key in map?

In C++ we can use arrays or vector as a key against to a int value like: map<vector<int> ,int > m; Can I do same in MATLAB by containers.


1 Answers

glib is an excellent library with many data structures and useful functions. It is used heavily in the GTK+ widget toolkit.

GLib provides advanced data structures, such as memory chunks, doubly- and singly-linked lists, hash tables, dynamic strings and string utilities, such as a lexical scanner, string chunks (groups of strings), dynamic arrays, balanced binary trees, N-ary trees, quarks (a two-way association of a string and a unique integer identifier), keyed data lists, relations and tuples. Caches provide memory management.

GLib implements functions that provide threads, thread programming and related facilities such as primitive variable access, mutexes, asynchronous queues, secure memory pools, message passing and logging, hook functions (callback registering) and timers. Also message passing facilities such as byte order conversion and I/O channels.

Some other features of GLib include:

  • standard macros
  • warnings and assertions
  • dynamic loading of modules
  • a type system, GType
  • an object system, GObject

http://library.gnome.org/devel/glib/

like image 77
Delan Azabani Avatar answered Oct 04 '22 11:10

Delan Azabani