xref: /original-bsd/lib/libcompat/4.3/lsearch.3 (revision 4c3b28fe)
Copyright (c) 1989 The Regents of the University of California.
All rights reserved.

Redistribution and use in source and binary forms are permitted
provided that the above copyright notice and this paragraph are
duplicated in all such forms and that any documentation,
advertising materials, and other materials related to such
distribution and use acknowledge that the software was developed
by the University of California, Berkeley. The name of the
University may not be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.

@(#)lsearch.3 5.2 (Berkeley) 02/21/90

LSEARCH 3 ""
C 7
NAME
lsearch, lfind, - linear searching routines
SYNOPSIS
char *
lsearch(const void *key, const void *base,
size_t *nelp, size_t width, 
int (*compar) (void *, void *));
char *
lfind(const void *key, const void *base,
size_t *nelp, size_t width,
int (*compar) (void *, void *));
DESCRIPTION
This interface was obsolete before it was written. It is available from the compatibility library, libcompat.

The functions lsearch , and lfind provide basic linear searching functionality.

Base is the pointer to the beginning of an array. Nelp is the current number of elements in the array, where each element is width bytes long. Compar is a comparison routine which is used to compare two elements. It is called with two arguments that point to the key object and to an array member, in that order, and must return an integer less than, equal to, or greater than zero if the key object is considered, respectively, to be less than, equal to, or greater than the array member.

Lsearch and lfind return a pointer into the array referenced by base where key is located. If key does not exist, lfind will return a NULL pointer and lsearch will add it to the array. When an element is added to the array by lsearch the location referenced by the argument nelp is incremented by one.

"SEE ALSO"
bsearch(3), hsearch(3), tsearch(3)