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"
36 .\"O lfind, lsearch \- linear search of an array
37 lfind, lsearch \- 配列を線形検索する
41 .B #include <search.h>
43 .BI "void *lfind(const void *" key ", const void *" base ", size_t *" nmemb ,
44 .BI " size_t " size ", int(*" compar ")(const void *, const void *));"
46 .BI "void *lsearch(const void *" key ", void *" base ", size_t *" nmemb ,
47 .BI " size_t " size ", int(*" compar ")(const void *, const void *));"
54 .\"O perform a linear search for
55 .\"O \fIkey\fP in the array \fIbase\fP which has \fI*nmemb\fP elements of
56 .\"O \fIsize\fP bytes each.
57 .\"O The comparison function referenced by
58 .\"O \fIcompar\fP is expected to have two arguments which point to the
59 .\"O \fIkey\fP object and to an array member, in that order, and which
60 .\"O returns zero if the \fIkey\fP object matches the array member, and
61 .\"O nonzero otherwise.
76 これは 2つの引き数を持ち、1つめの引き数が
78 を、2つめの引き数は配列メンバーを指す。また
82 が配列のメンバーとマッチしたなら 0、そうでなければ
87 .\"O does not find a matching element, then the \fIkey\fP
88 .\"O object is inserted at the end of the table, and \fI*nmemb\fP is
91 は、マッチする要素を見つけられなかったとき、
97 .\"O In particular, one should know that a matching element
98 .\"O exists, or that more room is available.
99 したがって、この関数を使用する際には、マッチする要素が存在するか、
100 もしくは配列に要素を追加するための領域があるか、を把握しておく必要がある。
101 .\"O .SH "RETURN VALUE"
104 .\"O returns a pointer to a matching member of the array, or
105 .\"O NULL if no match is found.
107 .\"O returns a pointer to
108 .\"O a matching member of the array, or to the newly added member if no
111 の返り値は、配列のマッチしたメンバーへのポインタである。
112 もしマッチするメンバーが見つからないと NULL を返す。
114 の返り値も、配列のマッチしたメンバーへのポインタである。
115 マッチするメンバーが見つからなかったときは、
116 新たにつけ加えたメンバーへのポインタを返す。
117 .\"O .SH "CONFORMING TO"
119 SVr4, 4.3BSD, POSIX.1-2001.
120 .\"O Present in libc since libc-4.6.27.
121 libc には libc-4.6.27 以降で実装されている。
124 .\"O The naming is unfortunate.