|
|
1.1 ! root 1: .\" Copyright (c) 1990 The Regents of the University of California. ! 2: .\" All rights reserved. ! 3: .\" ! 4: .\" Redistribution and use in source and binary forms are permitted ! 5: .\" provided that: (1) source distributions retain this entire copyright ! 6: .\" notice and comment, and (2) distributions including binaries display ! 7: .\" the following acknowledgement: ``This product includes software ! 8: .\" developed by the University of California, Berkeley and its contributors'' ! 9: .\" in the documentation or other materials provided with the distribution ! 10: .\" and in all advertising materials mentioning features or use of this ! 11: .\" software. Neither the name of the University nor the names of its ! 12: .\" contributors may be used to endorse or promote products derived ! 13: .\" from this software without specific prior written permission. ! 14: .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR ! 15: .\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED ! 16: .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ! 17: .\" ! 18: .\" @(#)bsearch.3 5.2 (Berkeley) 5/16/90 ! 19: .\" ! 20: .TH BSEARCH 3 "May 16, 1990" ! 21: .UC 7 ! 22: .SH NAME ! 23: bsearch - binary search of a sorted table ! 24: .SH SYNOPSIS ! 25: .nf ! 26: .ft B ! 27: #include <stdlib.h> ! 28: .sp ! 29: char * ! 30: bsearch(const void *key, const void *base, ! 31: size_t nmemb, size_t size, ! 32: int (*compar) (const void *, const void *)); ! 33: .ft R ! 34: .fi ! 35: .SH DESCRIPTION ! 36: The ! 37: .I bsearch ! 38: function searches an array of ! 39: .I nmemb ! 40: objects, the inital member of which is ! 41: pointed to by ! 42: .IR base , ! 43: for a member that matches the object pointed to by ! 44: .IR key . ! 45: The size of each member of the array is specified by ! 46: .I size . ! 47: .PP ! 48: The contents of the array should be in ascending sorted order according ! 49: to the comparison function referenced by ! 50: .IR compar . ! 51: .I Compar ! 52: is called with two arguments that point to the ! 53: .I key ! 54: object and to an array member, in that order, and must return an integer ! 55: less than, equal to, or greater than zero if the ! 56: .I key ! 57: object is considered, respectively, to be less than, equal to, or to ! 58: greater than the array member. ! 59: .PP ! 60: The ! 61: .I bsearch ! 62: function returns a pointer to a matching member of the array, or a null ! 63: pointer if no match is found. ! 64: If two members compare as equal, which member is matched is unspecified. ! 65: .SH "SEE ALSO" ! 66: hsearch(3), lsearch(3), qsort(3), tsearch(3) ! 67: .SH STANDARDS ! 68: .B Bsearch ! 69: conforms to ANSI X3.159-1989 (``ANSI C'').
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.