4.3BSD-Reno/src/lib/libcompat/4.3/lsearch.3

Compare this file to the similar file:
Show the results in this format:

.\" 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: (1) source distributions retain this entire copyright notice and
.\" comment, and (2) distributions including binaries display the following
.\" acknowledgement:  ``This product includes software developed by the
.\" University of California, Berkeley and its contributors'' in the
.\" documentation or other materials provided with the distribution and in
.\" all advertising materials mentioning features or use of this software.
.\" Neither the name of the University nor the names of its contributors may
.\" 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.3 (Berkeley) 6/23/90
.\"
.TH LSEARCH 3 "June 23, 1990"
.UC 7
.SH NAME
lsearch, lfind, \- linear searching routines
.SH SYNOPSIS
.ft B
.nf
char *
lsearch(const void *key, const void *base,
size_t *nelp, size_t width, 
int (*compar) (void *, void *));
.sp
char *
lfind(const void *key, const void *base,
size_t *nelp, size_t width,
int (*compar) (void *, void *));
.ft R
.SH DESCRIPTION
.ft B
This interface was obsolete before it was written.
It is available from the compatibility library, libcompat.
.ft R
.PP
The functions
.IR lsearch ,
and
.IR lfind
provide basic linear searching functionality.
.PP
.I Base
is the pointer to the beginning of an array.
.I Nelp
is the current number of elements in the array, where each element
is
.I width
bytes long.
.I Compar
is a comparison routine which is used to compare two elements.
It is called with two arguments that point to the 
.I 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 
.I key
object is considered, respectively, to be less than, equal to, or greater
than the array member.
.PP
.I Lsearch
and
.I lfind
return a pointer into the array referenced by
.I base
where
.I key
is located.
If
.I key
does not exist,
.I lfind
will return a NULL pointer and
.I lsearch
will add it to the array.
When an element is added to the array by
.I lsearch
the location referenced by the argument
.I nelp
is incremented by one.
.SH "SEE ALSO"
bsearch(3), hsearch(3), tsearch(3)