GNOME Bugzilla – Bug 50795
iterating over a range in a GTree
Last modified: 2011-02-18 16:13:45 UTC
I have uploaded glib-sandmann-990808-0.patch.gz to ftp.gtk.org/incoming. This patch implements a g_tree_lookup_range for the GTrees in GLib. As the name says, it implements a way to retrieve ranges from a GTree. Currently it is impossible to do this. The function g_tree_node_lookup_range does more comparisons than is actually needed; it would be more efficient but more difficult to read if subtrees that are known to be in the range were just added to list instead of comparing every node to the from_- and to_keys. Søren Sandmann (sandmann@daimi.au.dk)
Created attachment 229 [details] [review] Patch
Although I can see where, in some applications, the ability to fetch all keys n a range of a GTree is useful, I don't think this is quite the right interface; introducing the list and memory management is not what you would always want; I think an iteration is probably more what you want. The right interface, I believe, is is g_tree_foreach_range(). (And actually, along with, g_tree_foreach() should be added, because g_tree_traverse with anything other that G_IN_ORDER is completely useless.) I consider this pretty low priority because, basically, people don't use GTree very much.
I'm WONTFIX'ing this. I think GSequence (see bug 115664) is a better approach to solving this problem.