/doc/efun/assoc


SYNOPSIS

mixed assoc(mixed key, mixed *keys, mixed *data_or_fail, mixed fail);

DESCRIPTION

Searches a key in an alist.

Three modes of calling i ) With exactly two arguments, the second being an array which's first element is no array. In this case the entire array is searched for the key; -1 is returned if not found, else the index (like member_array(), but faster on sorted arrays).

ii) With two or three arguments, the second being an array which's first element is an array. The array has to have a second element of the same size; the key is searched in the first and the associated element of the second array that is element of second argument is returned if succesful; if not, 0 is returned, or the third argument, if given.

iii) With three or four arguments, the second being an array of keys (first element no array) and the second is a matching data array. Returns 0 or fourth argument (if given) for failure, or the matching entry in the array given as third argument for success.

Complexity : O( lg(n) ) , where n is the number of keys.

Return value is undefined if another list is given in place of a presorted key list.

SEE ALSO

alists
order_alist
insert_alist

| Home | Applied | Concepts | Efuns | Help | Intro | Lib | LPC | Prop | Obj | Sefuns | Std | W |

Nightfall@quest.tat.physik.uni-tuebingen.de
Automatically generated on Don, 11. Apr 1996