Re: Faster datastructure for lookups wanted



m94asr@xxxxxxxxx wrote:
Hi all,

maybe somebody can recommend me the right datastructure or
any other advice would be a big help.

My code spends most of its execution time doing lookups from
a hashtable with about 1M keys. The keys are strings and the values
are arrays of integers. Most of the time only of length 1.

I do not care how long the construction of the datastructure takes,
but the lookup should be as fast as possible.

xs.each{|x|
if found = hash[x]
#do sth. end
}

As others said already, a Hash is pretty much the fastest for the general case. How do your string keys look like? Maybe it is worth trying symbols instead of strings?

If you unveil a bit more about your application we might be able to come up with more suggestions.

Kind regards

robert
.



Relevant Pages

  • Re: Faster datastructure for lookups wanted
    ... The keys are strings and the values ... I do not care how long the construction of the datastructure takes, ... A multi-tiered hash might save a lot of lookup time if the data can ... If the strings are consistent about content, ...
    (comp.lang.ruby)
  • Faster datastructure for lookups wanted
    ... My code spends most of its execution time doing lookups from ... The keys are strings and the values ... I do not care how long the construction of the datastructure takes, ...
    (comp.lang.ruby)
  • Re: Ada Shootout program for K-Nucleotide (patches)
    ... execution time. ... and this particular hot spot had been cooled down twice: ... constrained strings of suitable fixed length ... function and a cute string equality function. ...
    (comp.lang.ada)
  • Re: Ada Shootout program for K-Nucleotide (patches)
    ... Ludovic Brenta wrote: ... execution time. ... constrained strings of suitable fixed length ... Operator subprograms seem to confuse the profiling programs, ...
    (comp.lang.ada)
  • Re: MFC updates and enhancements
    ... It stores a list of valid keys, ... the key file name, and prints only those lines in the data file, whose ... He tried developing it in Python, because developing in Python is very fast. ... version is C and what version is C++ from the execution time, ...
    (microsoft.public.vc.mfc)

Loading