/usr/share/doc/libbobcat4-dev/man/binarysearch.3.html is in libbobcat-dev 4.04.00-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | <!DOCTYPE html><html><head>
<meta charset="UTF-8">
<title>FBB::binary_search</title>
<style type="text/css">
figure {text-align: center;}
img {vertical-align: center;}
</style>
<link rev="made" href="mailto:Frank B. Brokken: f.b.brokken@rug.nl">
</head>
<body text="#27408B" bgcolor="#FFFAF0">
<hr/>
<h1 id="title">FBB::binary_search</h1>
<h2 id="author">libbobcat-dev_4.04.00-x.tar.gz</h2>
<h2 id="date">2005-2016</h2>
<!DOCTYPE html><html><head>
<meta charset="UTF-8">
<style type="text/css">
figure {text-align: center;}
img {vertical-align: center;}
figure {text-align: center;}
img {vertical-align: center;}
</style>
<link rev="made" href="mailto:Frank B. Brokken: f.b.brokken@rug.nl">
</head>
<body text="#27408B" bgcolor="#FFFAF0">
<hr/>
<h1 id="title"></h1>
<!DOCTYPE html><html><head>
<meta charset="UTF-8">
<title>FBB::binary_search(3bobcat)</title>
<style type="text/css">
figure {text-align: center;}
img {vertical-align: center;}
figure {text-align: center;}
img {vertical-align: center;}
figure {text-align: center;}
img {vertical-align: center;}
</style>
<link rev="made" href="mailto:Frank B. Brokken: f.b.brokken@rug.nl">
</head>
<body text="#27408B" bgcolor="#FFFAF0">
<hr/>
<h1 id="title">FBB::binary_search(3bobcat)</h1>
<h2 id="author">libbobcat-dev_4.04.00-x.tar.gz Binary search function</h2>
<h2 id="date">2005-2016</h2>
<p>
<h2 >NAME</h2>FBB::binary_search - Extensions to the STL binary_search function
template
<p>
<h2 >SYNOPSIS</h2>
<strong >#include <bobcat/binarysearch></strong><br/>
<p>
<h2 >DESCRIPTION</h2>
<p>
The <strong >FBB::binary_search</strong> function templates extend the STL <em >binary_search</em>
function template returning an iterator to the element found, instead of a
<strong >bool</strong> value informing the caller whether or not the searched for element is
present in a provided iterator range.
<p>
The <strong >bool</strong> value returned by the STL <em >binary_search</em> function template is
often not the kind of information the caller of the function is interested
in. Rather, the caller will often want to use <em >binary_search</em> in the way
<em >find_if</em> is used: returning an iterator to the found element or returning
the end-iterator if the element was not found. Whereas <em >find_if</em> does not
require the elements in the iterator range to be sorted, and thus will use a
linear search <em >binary_search</em> may use the sorted nature of the elements to
its advantage, using a binary search algorithm requiring <em >2 log N</em>
iterations to locate the searched for element rather than (on average) <em >N/2</em>
iterations. The <em >FBB::binary_search</em> algorithm uses this binary searching
process while at the same time allowing its use like <em >find_if</em>.
<p>
Since the <em >FBB::binary_search</em> function templates use the same number and
types of parameters as the <em >stl::binary_search</em> function templates the
explicit use of the <em >FBB</em> namespace will often be required in situations
where both function templates are made available to the compiler.
<p>
<h2 >NAMESPACE</h2>
<strong >FBB</strong><br/>
All constructors, members, operators and manipulators, mentioned in this
man-page, are defined in the namespace <strong >FBB</strong>.
<p>
<h2 >INHERITS FROM</h2>
-
<p>
<h2 >OVERLOADED FUNCTIONS</h2>
In the following description several template type parameters are
used. They are:
<ul>
<li> <strong >Iterator</strong> represents an iterator type;
<li> <strong >Type</strong> represents a value of the type to which <em >Iterator</em>
points.
<li> <strong >Comparator</strong> represents a comparator function or class type object
which was used to sort the elements to which the <em >Iterator</em> range refer;
</ul>
<ul>
<li> <strong >Iterator binary_search(Iterator begin, Iterator end, Type const
&value)</strong>:<br/>
Using a binary search algorithm <em >value</em> is searched for in the range
of elements referred to by the provided iterator range. If the value is found
an iterator pointing to this value is returned, otherwise <em >end</em> is
returned. The elements in the range must have been sorted by the
<em >Type::operator<()</em> function.
<li> <strong >Iterator binary_search(Iterator begin, Iterator end, Type const
&value, Comparator comparator)</strong>:<br/>
Using a binary search algorithm <em >value</em> is searched for in the range
of elements referred to by the provided iterator range. If the value is found
an iterator pointing to this value is returned, otherwise <em >end</em> is
returned. The elements and the provided value are compared using
<em >comparator(*iterator, value)</em> calls, where <em >*iterator</em> refers to an
object in the provided iterator range. The elements in the range must have
been sorted by the <em >Comparator</em> function or function object.
</ul>
<p>
<h2 >EXAMPLES</h2>
<pre >
#include <iostream>
#include <string>
#include "../binarysearch"
using namespace std;
using namespace FBB;
string words[] =
{
"eight", // alphabetically sorted number-names
"five",
"four",
"nine",
"one",
"seven",
"six",
"ten",
"three",
"two"
};
class Comparator
{
public:
bool operator()(string const &left, string const &right) const;
};
inline bool Comparator::operator()(string const &left,
string const &right) const
{
return left < right;
}
bool compFun(string const &left, string const &right)
{
return left < right;
}
int main()
{
string *ret = binary_search(words, words + 10, "five");
if (ret != words + 10)
cout << "five is at offset " << (ret - words) << endl;
ret = binary_search(words, words + 10, "grandpa");
if (ret == words + 10)
cout << "grandpa is not the name of a number\n";
ret = binary_search(words, words + 10, "five", Comparator());
if (ret != words + 10)
cout << "five is at offset " << (ret - words) << endl;
ret = binary_search(words, words + 10, "grandpa", compFun);
// or use: Comparator()
if (ret == words + 10)
cout << "grandpa is not the name of a number\n";
return 0;
}
</pre>
<p>
<h2 >FILES</h2>
<em >bobcat/binarysearch</em> - defines the template functions
<p>
<h2 >SEE ALSO</h2>
<strong >bobcat</strong>(7)
<p>
<h2 >BUGS</h2>
None reported.
<p>
<h2 >DISTRIBUTION FILES</h2>
<ul>
<li> <em >bobcat_4.04.00-x.dsc</em>: detached signature;
<li> <em >bobcat_4.04.00-x.tar.gz</em>: source archive;
<li> <em >bobcat_4.04.00-x_i386.changes</em>: change log;
<li> <em >libbobcat1_4.04.00-x_*.deb</em>: debian package holding the
libraries;
<li> <em >libbobcat1-dev_4.04.00-x_*.deb</em>: debian package holding the
libraries, headers and manual pages;
<li> <em >http://sourceforge.net/projects/bobcat</em>: public archive location;
</ul>
<p>
<h2 >BOBCAT</h2>
Bobcat is an acronym of `Brokken's Own Base Classes And Templates'.
<p>
<h2 >COPYRIGHT</h2>
This is free software, distributed under the terms of the
GNU General Public License (GPL).
<p>
<h2 >AUTHOR</h2>
Frank B. Brokken (<strong >f.b.brokken@rug.nl</strong>).
<p>
|