e r l a n g : c o o k b o o k

/ Erlang.HashIntroduction

This Web


WebHome 
WebChanges 
TOC
NewRecipe 
WebTopicList 
WebStatistics 

All Webs


Chicken
Cookbook
Erlang
Know
Main
Plugins
Sandbox
Scm
TWiki  

Erlang Links


Erlang.org
Erlang Wiki
ErlMan
Erlang Wiki
The Jungerl
Erlang-fr.org
Joe Armstrong
Lambda the Ultimate

Erlang Web Ring


[Prev]: Joe Armstrong's Page
[Next]: Joe Armstrong's Page

Introduction

Erlang provides native support for hash tables through the dict and ets modules. dict provides a simple dictionary implementation, in which values (of any Erlang type) can be stored and accessed by keys (Erlang terms). ets has a similar interface, but is designed for dealing with vast quantities of data.

To create a new dictionary, dict:new. Alternatively, you can generate a new dictionary from an existing list, using the dict:from_list function. The ets table implementation has similar features.

An additional advantage of the ets implementation is that it can be used as a bag, allowing multiple entries for the same key value (unlike standard dictionaries). This behavior is frequently useful is real-world problems.

The details will be discussed in the various recipes, but for now suffice it to say that:

> MyDict = dict:new().
> MyEts = ets:new("Test Ets", duplicate_bag).

creates a new hash table (dictionary) and ets table (named dictionary, in this case holding duplicate copies of entries). By default this table will compare keys using ==.

In the following recipes we will discuss ways to manipulate our newly created hash table.

Based on work by KarlaRamirez.

-- BrentAFulgham - 31 Aug 2004

CookbookForm
TopicType: Section
ParentTopic: HashChapter
TopicOrder: 010

 
 
Copyright © 2004 by the contributing authors. All material on the Erlang Cookbook web site is the property of the contributing authors.
This material can be redistributed and/or modified under the terms of the GNU Lesser General Public License (LGPL), version 2.1, as published by the Free Software Foundation.
Ideas, requests, problems regarding Schematics Cookbook? Send feedback.
/ You are Main.guest