MirBSD manpage: lfind(3), lsearch(3)

LSEARCH(3)                 BSD Programmer's Manual                  LSEARCH(3)

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

     The functions lsearch() and lfind() provide basic linear searching func-
     tionality.

     base is the pointer to the beginning of an array. The argument nelp is
     the current number of elements in the array, where each element is width
     bytes long. The compar function is a comparison routine which is used to
     compare two elements. It takes two arguments which point to the key ob-
     ject and to an array member, in that order, and must return an integer
     less than, equivalent to, or greater than zero if the key object is con-
     sidered, respectively, to be less than, equal to, or greater than the ar-
     ray member.

     The lsearch() and lfind() functions 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), db(3)

STANDARDS

     The lsearch() and lfind() functions conform to the IEEE Std 1003.1-2001
     ("POSIX.1") and X/Open Portability Guide Issue 4, Version 3 ("XPG4.3")
     specifications.

MirBSD #10-current               June 4, 1993                                1

Generated on 2022-12-24 01:00:14 by $MirOS: src/scripts/roff2htm,v 1.113 2022/12/21 23:14:31 tg Exp $ — This product includes material provided by mirabilos.

These manual pages and other documentation are copyrighted by their respective writers; their sources are available at the project’s CVSweb, AnonCVS and other mirrors. The rest is Copyright © 2002–2022 MirBSD.

This manual page’s HTML representation is supposed to be valid XHTML/1.1; if not, please send a bug report — diffs preferred.

Kontakt / Impressum & Datenschutzerklärung