[manual index][section index]

NAME

dict - list of string pairs

SYNOPSIS

include "dict.m";
dict := load Dictionary Dictionary->PATH;

Dict: adt {
	add: fn(d: self ref Dict, e: (string, string));
	delete: fn(d: self ref Dict, k: string);
	lookup: fn(d: self ref Dict, k: string): string;
	keys: fn(d: self ref Dict): list of string;
};

DESCRIPTION

Dict provides a simple string to string association list:

d.add(e)
Adds a new tuple e to the list, representing a new (key , value) pair.
d.delete(k)
Deletes all pairs with key k from the list.
d.lookup(k)
Tries to find a pair with key k and returns its associated value, or nil if the key was not found.
d.keys()
Returns a list of all keys in the list.

SOURCE

/appl/lib/dict.b

SEE ALSO

hash(2)

BUGS

No attempt is made to keep keys unique in the list; if more than one pair exists with the same key, then lookup will select one of them arbitrarily.

Computational overhead of lookup and deletion of keys is proportional to the number of pairs in the list.

DICT(2 ) Rev:  Thu Feb 15 14:43:27 GMT 2007