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!
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.
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.
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 ...
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.
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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With