Re: Speedup canvas itemconfigure -fill for many polygons.
- From: Alexandre Ferrieux <alexandre.ferrieux@xxxxxxxxx>
- Date: Mon, 31 Mar 2008 07:28:48 -0700 (PDT)
On Mar 31, 4:24 pm, Alexandre Ferrieux <alexandre.ferri...@xxxxxxxxx>
wrote:
On Mar 31, 1:59 pm, Mats <mats...@xxxxxxxxx> wrote:
Well, to answer this one I'd add a third hashtable
mapping (tag,item)->position-in-list. Granted, that
means additional housekeeping, but all operations then are O(1).
Do you think you can explain a bit more?
Can I create a hash entry with two keys, or do
I just combine them somehow to a single key?
Just combine. "$tag,$id" should do the job since ids contain only
digits (hence no comma). In Tcl pseudo-code:
addtag --> if {![info exists tab($tag,$id)]} {
set pos [llength $tags($id)]
set tab($tag,$id) $pos
lappend tags($id) $pos
}
dtag --> if {[info exists tab($tag,$id)]} {
set pos $tab($tag,$id)
unset tab($tag,$id)
set tags($id) [lreplace $tags($id) $pos $pos]
}
remove item --> foreach tag $tags($id) {unset tab($tag,$id)}
unset tags($id)
-Alex
I like to add that the [lreplace] and [foreach] above are actually
O(M), where M is the number of tags a given item may have, so the
above implementation targets small Ms (which are fairly frequent IMO).
-Alex
.
- References:
- Speedup canvas itemconfigure -fill for many polygons.
- From: max vorticity
- Re: Speedup canvas itemconfigure -fill for many polygons.
- From: Alexandre Ferrieux
- Re: Speedup canvas itemconfigure -fill for many polygons.
- From: max vorticity
- Re: Speedup canvas itemconfigure -fill for many polygons.
- From: Alexandre Ferrieux
- Re: Speedup canvas itemconfigure -fill for many polygons.
- From: Mats
- Re: Speedup canvas itemconfigure -fill for many polygons.
- From: Alexandre Ferrieux
- Re: Speedup canvas itemconfigure -fill for many polygons.
- From: Mats
- Re: Speedup canvas itemconfigure -fill for many polygons.
- From: Alexandre Ferrieux
- Re: Speedup canvas itemconfigure -fill for many polygons.
- From: Mats
- Re: Speedup canvas itemconfigure -fill for many polygons.
- From: Alexandre Ferrieux
- Speedup canvas itemconfigure -fill for many polygons.
- Prev by Date: Re: Speedup canvas itemconfigure -fill for many polygons.
- Next by Date: Re: send command
- Previous by thread: Re: Speedup canvas itemconfigure -fill for many polygons.
- Next by thread: Re: Speedup canvas itemconfigure -fill for many polygons.
- Index(es):
Relevant Pages
|