data structure for sets of strings
I was wondering if anyone could suggest a data structure for storing strings in two mutually exclusive sets. The operations would include adding and removin开发者_如何学Cg a string from a set, moving a string from one set to the other, and returning the number of strings in each set. I'm considering a trie, but I'm not sure about returning the number of strings in each set.
I would like to implement it in C.
GLib has a hash table implementation you could use: http://developer.gnome.org/glib/2.28/glib-Hash-Tables.html
You could use two priority queues like Self-balancing binary search trees for each set. You could also use a treap.
精彩评论