Quick Way to Implement Dictionary in C

Section 6.6 of The C Programming Language presents a simple dictionary (hashtable) data structure. I don’t think a useful dictionary implementation could get any simpler than this. For your convenience, I reproduce the code here. Note that if the hashes of two strings collide, it may lead to an O(n) lookup time. You can reduce the likelihood of collisions … Read more

Why does the C++ STL not provide any “tree” containers?

There are two reasons you could want to use a tree: You want to mirror the problem using a tree-like structure:For this we have boost graph library Or you want a container that has tree like access characteristics For this we have std::map (and std::multimap) std::set (and std::multiset) Basically the characteristics of these two containers is such that they practically … Read more

golang why don’t we have a set datastructure [closed]

Partly, because Go doesn’t have generics (so you would need one set-type for every type, or fall back on reflection, which is rather inefficient). Partly, because if all you need is “add/remove individual elements to a set” and “relatively space-efficient”, you can get a fair bit of that simply by using a map[yourtype]bool (and set the value … Read more