Re: Speedup canvas itemconfigure -fill for many polygons.



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
.



Relevant Pages

  • Re: Speedup canvas itemconfigure -fill for many polygons.
    ... Can I create a hash entry with two keys, ... set pos ... remove item --> foreach tag $tags{unset tab} ...
    (comp.lang.tcl)
  • Re: Altenative of PHP Function "Unset" in ASP
    ... I take it you are talking about ASP.Net...you won't be able to unset ... of keys you don't want and as you are looping through the collection, ... sure the key isn't in your string[]. ... > ASP any help will be appreciated...I have done most of it but I cant find ...
    (microsoft.public.dotnet.framework.aspnet)