From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Teemu Likonen Newsgroups: gmane.emacs.help Subject: Re: Hash tables - how to look up values? Date: Wed, 04 Jul 2012 17:09:30 +0300 Message-ID: <871ukrfwit.fsf@imladris.arda> References: <873957d4di.fsf@googlemail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1341410993 23520 80.91.229.3 (4 Jul 2012 14:09:53 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 4 Jul 2012 14:09:53 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Thorsten Jolitz Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Jul 04 16:09:51 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SmQH9-0005u1-Je for geh-help-gnu-emacs@m.gmane.org; Wed, 04 Jul 2012 16:09:51 +0200 Original-Received: from localhost ([::1]:54131 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SmQH8-0005em-GN for geh-help-gnu-emacs@m.gmane.org; Wed, 04 Jul 2012 10:09:50 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:46172) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SmQGz-0005eY-9s for help-gnu-emacs@gnu.org; Wed, 04 Jul 2012 10:09:46 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SmQGt-0001a2-2z for help-gnu-emacs@gnu.org; Wed, 04 Jul 2012 10:09:40 -0400 Original-Received: from mta-out.inet.fi ([195.156.147.13]:38359 helo=kirsi1.inet.fi) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SmQGs-0001Zi-RS for help-gnu-emacs@gnu.org; Wed, 04 Jul 2012 10:09:34 -0400 Original-Received: from imladris.arda (84.251.23.203) by kirsi1.inet.fi (8.5.140.03) (authenticated as likote-3) id 4FD08A2301A07A76; Wed, 4 Jul 2012 17:09:32 +0300 Original-Received: from dtw by imladris.arda with local (Exim 4.72) (envelope-from ) id 1SmQGp-0006aa-2N; Wed, 04 Jul 2012 17:09:31 +0300 In-Reply-To: <873957d4di.fsf@googlemail.com> (Thorsten Jolitz's message of "Wed, 04 Jul 2012 15:48:09 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 195.156.147.13 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:85654 Archived-At: Thorsten Jolitz [2012-07-04 15:48:09 +0200] wrote: > that returns the corresponding key of a known (string) value in a hash > table (similar to 'rassoc' for alists). > > I could not find such a function - does it exist already? There is no such thing. You need to traverse the hash table with maphash and look for your value. This is obviously slower than gethash but this is how hash tables work. If you need fast two-way access in your programs you could create your own access functions which synchronize two hash tables and thus get fast two-way access.