help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fastest data structure for a hash-like lookup


From: Kevin Rodgers
Subject: Re: fastest data structure for a hash-like lookup
Date: Wed, 04 Jun 2003 13:05:28 -0600
User-agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:0.9.4.1) Gecko/20020406 Netscape6/6.2.2

Florian von Savigny wrote:

I need a data structure that can be accessed via a key (the keys are
unique), which points to a value that is a list (in the general sense,
not in the elisp sense) of three elements. [In Perl, I would implement
this as a hash where the values are references to lists.]. It may also
be thought of as a structure with keys that point to "a set of three
values" each. The structure would be quite large and not be
manipulated by the elisp program, but merely serve as a lookup table.

I think I've read something that sounded like a vector would be the
right thing to use (is not changed, is fast), but I haven't found any
advice on that. Or is it an obarray? A property list? An alist? An
array? A combination of two? And how would that look like?

You definitly want to use an obarray.  From each key string, generate a symbol
in the obarray whose value is the list you want to look up.

(defvar my-hash (make-vector some-large-prime-number 0))

(defun my-hash-set (key value)
  (set (intern key my-hash) value))

(defun my-hash-get (key)
  (symbol-value (intern-soft key my-hash)))

--
<a href="mailto:&lt;kevin.rodgers&#64;ihs.com&gt;";>Kevin Rodgers</a>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]