This section is based on catpages contributed by Mainichi Communications, Inc. Translated by: MYCOM team Converted by: Japanese Online Manual Project <man-jp@jp.FreeBSD.ORG> Submitted by: Kazuo Horikawa <k-horik@yk.rim.or.jp>
104 lines
3.3 KiB
Groff
104 lines
3.3 KiB
Groff
.\" Copyright (c) 1989, 1991, 1993
|
|
.\" The Regents of the University of California. All rights reserved.
|
|
.\"
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
.\" modification, are permitted provided that the following conditions
|
|
.\" are met:
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
.\" 3. All advertising materials mentioning features or use of this software
|
|
.\" must display the following acknowledgement:
|
|
.\" This product includes software developed by the University of
|
|
.\" California, Berkeley and its contributors.
|
|
.\" 4. Neither the name of the University nor the names of its contributors
|
|
.\" may be used to endorse or promote products derived from this software
|
|
.\" without specific prior written permission.
|
|
.\"
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
.\" SUCH DAMAGE.
|
|
.\"
|
|
.\" @(#)lsearch.3 8.1 (Berkeley) 6/4/93
|
|
.\"
|
|
.Dd June 4, 1993
|
|
.Dt LSEARCH 3
|
|
.Os
|
|
.Sh 名称
|
|
.Nm lsearch ,
|
|
.Nm lfind
|
|
.Nd 線形探索ルーチン
|
|
.Sh 書式
|
|
.Fd #include <sys/types.h>
|
|
.Ft char *
|
|
.Fn lsearch "const void *key" "const void *base" "size_t *nelp" "size_t width" "int (*compar)(void *, void *)"
|
|
.Ft char *
|
|
.Fn lfind "const void *key" "const void *base" "size_t *nelp" "size_t width" "int (*compar)(void *, void *)"
|
|
.Sh 解説
|
|
.Bf -symbolic
|
|
このインタフェースは、これが書かれるより前に時代遅れでした。
|
|
これは互換ライブラリ libcompat から利用可能となっています。
|
|
.Ef
|
|
.Pp
|
|
関数
|
|
.Fn lsearch
|
|
及び
|
|
.Fn lfind
|
|
は基本的な線形探索機能を提供します。
|
|
.Pp
|
|
.Fa base
|
|
は配列の先頭を指すポインタです。
|
|
引数
|
|
.Fa nelp
|
|
は配列の現在の要素数であり、
|
|
各要素サイズのバイト長は
|
|
.Fa width
|
|
です。
|
|
関数
|
|
.Fa compar
|
|
は、2 つの要素比較に使用される比較ルーチンです。
|
|
この関数は、2 つの引数、
|
|
比較対象を指すポインタ
|
|
.Fa key
|
|
と配列メンバーを指すポインタを、
|
|
この順序でとります。
|
|
そして、
|
|
.Fa key
|
|
が指す比較対象が配列のメンバより、小さい、等しい、大きいと
|
|
考えられるそれぞれの場合について、
|
|
負、 0 、正の整数を返さなければなりません。
|
|
.Pp
|
|
関数
|
|
.Fn lsearch
|
|
及び
|
|
.Fn lfind
|
|
は、
|
|
.Fa base
|
|
によって参照される配列の中で
|
|
.Fa key
|
|
が位置するポインタを返します。
|
|
もし
|
|
.Fa key
|
|
が存在しない場合、
|
|
.Fn lfind
|
|
はヌルポインタを返し、
|
|
.Fn lsearch
|
|
はそれを配列に追加します。
|
|
.Fn lsearch
|
|
要素が配列に追加されると、
|
|
により配列要素が追加されると、引数
|
|
.Fa nelp
|
|
によって参照される位置が 1 つ加算されます。
|
|
.Sh 関連項目
|
|
.Xr bsearch 3 ,
|
|
.Xr db 3
|