[Gtk-sharp-list] Preventing Dups In a ListStore
Adam Tauno Williams
adam at morrison-ind.com
Sat Jan 5 18:46:39 EST 2008
> On Jan 4, 2008 10:36 PM, Michael Hutchinson <m.j.hutchinson at gmail.com> wrote:
> > AFAIK you'd have to iterate it (though ForEach will simplify this). Of
> > course, that's what a Contains () call would do anyway -- if you want
> > O(1) contains calls, you'd need a hashtable, but a list obviously
> > needs... a list.
> Yes, that's the problem. It would be O(n) for a naïve approach.
I've made a, probably rather crude, solution by extending ListStore. I
had hoped to just override AppendValues but those methods aren't
virtual. So I went with the keep-an-index approach.
> Another option (besides hashtables, trees, etc) would be to store an
> additional field on each entity stating that it was already included
> or not, but of course this depends on how your code works, as it may
> be not possible.
An object can appear in perhaps dozens of lists, so that wouldn't really
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 194 bytes
Desc: This is a digitally signed message part
Url : http://lists.ximian.com/pipermail/gtk-sharp-list/attachments/20080105/636d5b59/attachment.bin
More information about the Gtk-sharp-list