Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

bsearch(3C)

qsort(3C)

LSEARCH(3C)  —  UNIX 3.0

NAME

lsearch − linear search and update

SYNOPSIS

char ∗lsearch (key, base, nelp, width, compar)
char ∗key;
char ∗base;
int ∗nelp;
int width;
int (∗compar)();

DESCRIPTION

Lsearch is a linear search routine generalized from Knuth (6.1) Algorithm Q.  It returns a pointer into a table indicating the location at which a datum may be found.  If the item does not occur, it is added at the end of the table.  The first argument is a pointer to the datum to be located in the table.  The second argument is a pointer to the base of the table.  The third is the address of an integer containing the number of items in the table.  It is incremented if the item is added to the table.  The fourth is the width of an element in bytes.  The last is the name of the comparison routine.  It is called with two arguments which are pointers to the elements being compared.  The routine must return zero if the items are equal and non-zero otherwise. 

BUGS

Unpredictable events can occur if there is not enough room in the table to add a new item. 

SEE ALSO

bsearch(3C), qsort(3C). 

May 16, 1980

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026