OSDN Git Service

Update README
[linuxjm/LDP_man-pages.git] / release / man3 / lsearch.3
1 .\" Copyright 1995 Jim Van Zandt <jrv@vanzandt.mv.com>
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
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.
7 .\"
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.
12 .\"
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
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .\" Corrected prototype and include, aeb, 990927
26 .\"*******************************************************************
27 .\"
28 .\" This file was generated with po4a. Translate the source file.
29 .\"
30 .\"*******************************************************************
31 .\"
32 .\" Japanese Version Copyright (c) 1998 Ueyama Rui
33 .\"         all rights reserved.
34 .\" Translated 1998-05-23, Ueyama Rui <rui@linux.or.jp>
35 .\" Updated 2005-02-26, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
36 .\"
37 .TH LSEARCH 3 1999\-09\-27 GNU "Linux Programmer's Manual"
38 .SH 名前
39 lfind, lsearch \- 配列を線形検索する
40 .SH 書式
41 .nf
42 \fB#include <search.h>\fP
43 .sp
44 \fBvoid *lfind(const void *\fP\fIkey\fP\fB, const void *\fP\fIbase\fP\fB, size_t *\fP\fInmemb\fP\fB,\fP
45 \fB         size_t \fP\fIsize\fP\fB, int(*\fP\fIcompar\fP\fB)(const void *, const void *));\fP
46 .sp
47 \fBvoid *lsearch(const void *\fP\fIkey\fP\fB, void *\fP\fIbase\fP\fB, size_t *\fP\fInmemb\fP\fB,\fP
48 \fB         size_t \fP\fIsize\fP\fB, int(*\fP\fIcompar\fP\fB)(const void *, const void *));\fP
49 .fi
50 .SH 説明
51 \fBlfind\fP()  と \fBlsearch\fP()  は、 \fIsize\fP バイトの要素 \fI*nmemb\fP 個からなる配列 \fIbase\fP から、
52 \fIkey\fP を線形検索する。比較を行うのは \fIcompar\fP が参照している関数で、 これは 2つの引き数を持ち、1つめの引き数が \fIkey\fP
53 を、2つめの引き数は配列メンバーを指す。また \fIcompar\fP は、 \fIkey\fP が配列のメンバーとマッチしたなら 0、そうでなければ 0
54 以外を返すことが期待されている。
55 .PP
56 \fBlsearch\fP()  は、マッチする要素を見つけられなかったとき、 配列の最後に \fIkey\fP をつけ加える。そして \fI*nmemb\fP を 1
57 ふやす。 したがって、この関数を使用する際には、マッチする要素が存在するか、 もしくは配列に要素を追加するための領域があるか、を把握しておく必要がある。
58 .SH 返り値
59 \fBlfind\fP()  の返り値は、配列のマッチしたメンバーへのポインターである。 もしマッチするメンバーが見つからないと NULL を返す。
60 \fBlsearch\fP()  の返り値も、配列のマッチしたメンバーへのポインターである。 マッチするメンバーが見つからなかったときは、
61 新たにつけ加えたメンバーへのポインターを返す。
62 .SH 準拠
63 SVr4, 4.3BSD, POSIX.1\-2001.  libc には libc\-4.6.27 以降で実装されている。
64 .SH バグ
65 関数の名前の選び方がよくない。
66 .SH 関連項目
67 \fBbsearch\fP(3), \fBhsearch\fP(3), \fBtsearch\fP(3)
68 .SH この文書について
69 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.79 の一部
70 である。プロジェクトの説明とバグ報告に関する情報は
71 http://www.kernel.org/doc/man\-pages/ に書かれている。