Re: Data structure run-time in tcl...
- From: Andreas Kupries <akupries@xxxxxxx>
- Date: Wed, 10 Aug 2011 19:35:33 -0700
Aric Bills <aric.bills@xxxxxxxxx> writes:
On Jul 11, 1:17 pm, Eric Thorne <et.newsgro...@xxxxxxxxx> wrote:
God day tcl-ers...
I'm a long time perl user new to tcl and wrapping my head around non-
perl based hash data structures is proving difficult for me.
For those of you that know perl, imagine this:
Thoughts, ideas?
Thanks,
Eric
Here are three possible approaches, any of which will speed things up
for you:
Method 2: flat Tcl associative array
if { [regexp {(\S+)_X(\d+)Y(\d+)} $tile full_match type x y] } {
lappend counts($type,X,$y) $x
lappend counts($type,Y,$x) $y
}
Method 2 doesn't give you a dict or nested data, but arrays can be
converted to dicts and many of the things you might need nesting for
you can fake or work around. This is the fastest of the three methods
both for data storage and retrieval. If $type, $x, or $y can contain
commas, you'd need to choose a different delimiter.
Or simply construct the key using [list $type Y $x], etc.
--
So long,
Andreas Kupries <akupries@xxxxxxx>
<http://www.purl.org/NET/akupries/>
Developer @ <http://www.activestate.com/>
-------------------------------------------------------------------------------
.
- Prev by Date: Re: [tcl/tk] Question - "entry" field size
- Next by Date: TIP #388: Extending Unicode literals past the BMP
- Previous by thread: Re: URGENT - Understanding TCL Global Variable Syntax
- Next by thread: TIP #388: Extending Unicode literals past the BMP
- Index(es):