![]() ![]() ![]() This only works in some cases (lists, trees, and chained hash tables), but basically the idea is that you put the shared part of the data structure as a struct at the front (or in the middle if the implementation does some offsetof math) of your type, and then all the operations use that. This is still not ideal for some applications that require many containers (this is the minority of all applications, in my experience!). Doesn't end up being a problem nearly* as often as some people think (e.g., you don't spend much time writing data structure code), as you only write the subset for what you actually need at the time (A hash-table is fairly easy if you only need get-or-insert, exists, and clear), and you don't tend to need these data structures as much as you might think. In my experience, this is the most common for performance-critical code. Custom data structures for your use-case. ![]() no type safety, poor performance, frequently requires allocations if you want to store more than sizeof(void ), forces the compiler to generate poor code. Writing a generic implementation that takes a void* (or suitable "any" type). The two can co-exist quite nicely - I can easily see a glib application using klib data structures along critical paths. Klib is written for doing data analysis and serialization in C, with two releases in four years and no stability claims. Most of glib's data structures are highly unoptimized simply because they don't need to run in critical paths of whatever applications they're used in optimizing would be mostly premature (with some caveats GSequence was added because of the need for a higher performance list-like container, GHashTable got a lot of love a few years ago because it turned out to be awful, etc). Glib is a platform and portability library that evolved away from gtk+, with the goal being to make event driven programming simpler, both for system daemons and Gtk+ applications. This is really not a "standalone and lightweight glib", this is a generic data structure library in C, and it's quite blatantly obvious they're designed for different purposes. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |