1 .\" Hey Emacs! This file is -*- nroff -*- source.
2 .\" Copyright 1995 Jim Van Zandt <jrv@vanzandt.mv.com>
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein. The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
24 .\" Corrected prototype and include, aeb, 990927
26 .\" Japanese Version Copyright (c) 1998 Ueyama Rui
27 .\" all rights reserved.
28 .\" Translated 1998-05-23, Ueyama Rui <rui@linux.or.jp>
29 .\" Updated 2005-02-26, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
31 .\"WORD: linear search 線形検索
33 .TH LSEARCH 3 1999-09-27 "GNU" "Linux Programmer's Manual"
35 lfind, lsearch \- 配列を線形検索する
38 .B #include <search.h>
40 .BI "void *lfind(const void *" key ", const void *" base ", size_t *" nmemb ,
41 .BI " size_t " size ", int(*" compar ")(const void *, const void *));"
43 .BI "void *lsearch(const void *" key ", void *" base ", size_t *" nmemb ,
44 .BI " size_t " size ", int(*" compar ")(const void *, const void *));"
61 これは 2つの引き数を持ち、1つめの引き数が
63 を、2つめの引き数は配列メンバーを指す。また
67 が配列のメンバーとマッチしたなら 0、そうでなければ
71 は、マッチする要素を見つけられなかったとき、
77 したがって、この関数を使用する際には、マッチする要素が存在するか、
78 もしくは配列に要素を追加するための領域があるか、を把握しておく必要がある。
81 の返り値は、配列のマッチしたメンバーへのポインタである。
82 もしマッチするメンバーが見つからないと NULL を返す。
84 の返り値も、配列のマッチしたメンバーへのポインタである。
85 マッチするメンバーが見つからなかったときは、
86 新たにつけ加えたメンバーへのポインタを返す。
88 SVr4, 4.3BSD, POSIX.1-2001.
89 libc には libc-4.6.27 以降で実装されている。