From: lawrence mitchell <wence@gmx.li>
Subject: Re: fastest data structure for a hash-like lookup
Date: Wed, 04 Jun 2003 19:57:32 +0100 [thread overview]
Message-ID: <?fnord?87he75fz6r.fsf@ID-97657.usr.dfncis.de> (raw)
In-Reply-To: m3znkxpsl1.fsf@russel.teuto37
Florian von Savigny wrote:
> Hi folks,
> 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?
Hmm, how about a hash-table :).
/----[ C-h f make-hash-table RET ]
| make-hash-table is a built-in function.
| (make-hash-table &rest KEYWORD-ARGS)
|
| Create and return a new hash table.
|
| Arguments are specified as keyword/argument pairs. The following
| arguments are defined:
|
| [...]
|
\----
In Emacs 21, hash tables are built in, in Emacs 20, you may need
to do (require 'cl), to get at the CL package's hash tables.
[...]
If you, in fact, do not want to use hash tables, then, for
random access, a vector might be the best idea, however, IIRC,
you can't access an element via a key with a vector. So, you
might be better-off with an alist/plist, both of these have
linear access time.
--
lawrence mitchell <wence@gmx.li>
next prev parent reply other threads:[~2003-06-04 18:57 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-06-04 19:10 fastest data structure for a hash-like lookup Florian von Savigny
2003-06-04 18:57 ` lawrence mitchell [this message]
2003-06-04 19:05 ` Kevin Rodgers
2003-06-04 20:58 ` Stefan Monnier
2003-06-04 23:45 ` Florian von Savigny
2003-06-04 23:09 ` Stefan Monnier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='?fnord?87he75fz6r.fsf@ID-97657.usr.dfncis.de' \
--to=wence@gmx.li \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).