sets in glib



Hello, there.

Is there yet a set type in glib? You can use hash tables as sets, just ignore
the "value", but I'd say a set is a fundamental enough abstract data type to
deserve a dedicated implementation.. All you really need is a slightly
modified ghashtable.c. I hacked one some time ago, you can see it at
http://iki.fi/la/ghashset.c

It should be noted that a hash table is a dictionary, and a dictionary is
really just a set of key-value pairs. However, often the key is part of the
"value" object, and it's a waste to have an additional redundant field in
every hash node, but rather one should have just compare and hash functions
that only use the key part of the object.

So, what do you say?


Lauri Alanko
la@iki.fi



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]