OSDN Git Service

70ca7532d0539fb546e2aa0c316a9fd85532d775
[linuxjm/LDP_man-pages.git] / draft / man3 / lsearch.3
1 .\" Hey Emacs! This file is -*- nroff -*- source.
2 .\" Copyright 1995 Jim Van Zandt <jrv@vanzandt.mv.com>
3 .\"
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 .\"
24 .\" Corrected prototype and include, aeb, 990927
25 .\"
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>
30 .\"
31 .\"WORD:        linear search   線形検索
32 .\"
33 .TH LSEARCH 3  1999-09-27 "GNU" "Linux Programmer's Manual"
34 .\"O .SH NAME
35 .SH 名前
36 .\"O lfind, lsearch \- linear search of an array
37 lfind, lsearch \- 配列を線形検索する
38 .\"O .SH SYNOPSIS
39 .SH 書式
40 .nf
41 .B #include <search.h>
42 .sp
43 .BI "void *lfind(const void *" key ", const void *" base ", size_t *" nmemb ,
44 .BI "         size_t " size ", int(*" compar ")(const void *, const void *));"
45 .sp
46 .BI "void *lsearch(const void *" key ", void *" base ", size_t *" nmemb ,
47 .BI "         size_t " size ", int(*" compar ")(const void *, const void *));"
48 .fi
49 .\"O .SH DESCRIPTION
50 .SH 説明
51 .\"O .BR lfind ()
52 .\"O and
53 .\"O .BR lsearch ()
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.
62 .BR lfind ()
63
64 .BR lsearch ()
65 は、
66 .I size
67 バイトの要素
68 .I *nmemb
69 個からなる配列
70 .I base
71 から、
72 .I key
73 を線形検索する。比較を行うのは
74 .I compar
75 が参照している関数で、
76 これは 2つの引き数を持ち、1つめの引き数が
77 .I key
78 を、2つめの引き数は配列メンバーを指す。また
79 .I compar
80 は、
81 .I key
82 が配列のメンバーとマッチしたなら 0、そうでなければ
83 0 以外を返すことが期待されている。
84 .PP
85 .\"O If
86 .\"O .BR lsearch ()
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
89 .\"O incremented.
90 .BR lsearch ()
91 は、マッチする要素を見つけられなかったとき、
92 配列の最後に
93 .I key
94 をつけ加える。そして
95 .I *nmemb
96 を 1 ふやす。
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"
102 .SH 返り値
103 .\"O .BR lfind ()
104 .\"O returns a pointer to a matching member of the array, or
105 .\"O NULL if no match is found.
106 .\"O .BR lsearch ()
107 .\"O returns a pointer to
108 .\"O a matching member of the array, or to the newly added member if no
109 .\"O match is found.
110 .BR lfind ()
111 の返り値は、配列のマッチしたメンバーへのポインタである。
112 もしマッチするメンバーが見つからないと NULL を返す。
113 .BR lsearch ()
114 の返り値も、配列のマッチしたメンバーへのポインタである。
115 マッチするメンバーが見つからなかったときは、
116 新たにつけ加えたメンバーへのポインタを返す。
117 .\"O .SH "CONFORMING TO"
118 .SH 準拠
119 SVr4, 4.3BSD, POSIX.1-2001.
120 .\"O Present in libc since libc-4.6.27.
121 libc には libc-4.6.27 以降で実装されている。
122 .\"O .SH BUGS
123 .SH バグ
124 .\"O The naming is unfortunate.
125 関数の名前の選び方がよくない。
126 .\"O .SH "SEE ALSO"
127 .SH 関連項目
128 .BR bsearch (3),
129 .BR hsearch (3),
130 .BR tsearch (3)