Menu

#1 First part for the Hash Tables section

closed-accepted
None
5
2002-04-25
2002-04-03
No

Introduction

Hash Tables are a powerful data structure, associating
keys with values in a very efficient way. Hash Tables
are often preferred over association lists whenever
performance is an issue, but they introduce a little
overhead that makes assoc lists better if there are
only a few key-value pairs to maintain.

Creating a Hash Table

Hash Tables are created using the function
MAKE-HASH-TABLE. It has no required argument. Its most
used optional keyword argument is :TEST, specifying the
function used to test the equality of keys.

Getting a value from a Hash Table

The function GETHASH takes two required arguments: a
key and a hash table. It returns two values: the value
corresponding to the key in the hash table (or NIL if
not found), and a boolean indicating whether the key
was found in the table. That second value is necessary
since NIL is a valid value in a key-value pair, so
getting NIL as first value from GETHASH does not
necessarily mean that the key was not found in the
table.

Discussion

  • Edi Weitz

    Edi Weitz - 2002-04-03

    Logged In: YES
    user_id=192106

    assigned to Matthieu who now has developer status

     
  • Matthieu Villeneuve

    • assigned_to: nobody --> mvilleneuve
    • status: open --> open-fixed
     
  • Edi Weitz

    Edi Weitz - 2002-04-25
    • status: open-fixed --> closed-accepted
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.