/usr/share/doc/libbobcat4-dev/man/ptriter.3.html is in libbobcat-dev 4.08.02-2build1.
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 | <!DOCTYPE html><html><head>
<meta charset="UTF-8">
<title>FBB::PtrIter(3bobcat)</title>
<style type="text/css">
figure {text-align: center;}
img {vertical-align: center;}
.XXfc {margin-left:auto;margin-right:auto;}
.XXtc {text-align: center;}
.XXtl {text-align: left;}
.XXtr {text-align: right;}
.XXvt {vertical-align: top;}
.XXvb {vertical-align: bottom;}
</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::PtrIter(3bobcat)</h1>
<h2 id="author">Error handler<br/>(libbobcat-dev_4.08.02-x.tar.gz)</h2>
<h2 id="date">2005-2017</h2>
<p>
<h2 >NAME</h2>FBB::PtrIter - Iterator returning pointer when dereferenced
<p>
<h2 >SYNOPSIS</h2>
<strong >#include <bobcat/ptriter></strong><br/>
<p>
<h2 >DESCRIPTION</h2>
<p>
The <em >PtrIter</em> class template implements an input iterator whose
<em >operator*</em> returns the address of the element the iterator refers to.
Consider a <em >std::unordered_map<std::string, DataType></em>. Its <em >begin</em> member
returns an iterator whose <em >operator*</em> returns a <em >std::pair<std::string,
DataType> (const) &</em>. This is usually what you want, but now assume we want to
display the map's contents, sorted by its keys. Sorting can simply be
performed by defining a support vector containing pointers to the elements in
the map, and then sorting the strings the pointers point at.
<p>
<em >PtrIter</em> is a tool that can be used to construct such a support vector, as
shown in the <strong >EXAMPLE</strong> section.
<p>
<em >PtrIter</em> is a class template requiring one template type parameter:
<em >Iterator</em>, the iterator's type (e.g., <em >vector<string>::iterator</em>)
<p>
<em >PtrIter</em>'s users don't have to specify <em >PtrIter</em>'s template type. The
function template <em >ptrIter</em>, when provided with an iterator returns the
matching <em >PtrIter</em> object.
<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>
<em >std::iterator<std::input_iterator_tag, ...></em>
<p>
<h2 >FREE FUNCTION</h2>
<ul>
<li> <strong >PtrIter<Iterator> ptrIter(Iterator const &iter)</strong>:<br/>
this function template returns a <em >PtrIter</em> object for the function's
<em >Iterator</em> argument. This function template simplyfies the construction of a
<em >PtrIter</em> as no template parameters need to be specified (see also the
<strong >EXAMPLE</strong> section)
</ul>
<p>
<h2 >CONSTRUCTORS</h2>
<ul>
<li> <strong >PtrIter(Iterator const &iter)</strong>:<br/>
The <em >iter</em> parameter must be initialized with an existing input
iterator, offering <em >operator*, operator++, operator==</em> and <em >operator!=</em>.
As <em >PtrIter</em> is a class template, its template type parameters must be
specified when defining a <em >PtrIter</em> object. E.g.,
<pre>
PtrIter<set<string>::iterator> PtrIter(mySet.begin());
</pre>
</ul>
The copy and move constructors are available.
<p>
<h2 >OVERLOADED OPERATORS</h2>
<ul>
<li> <strong >PtrType operator*() const</strong>:<br/>
the address of the entity the iterator refers to is returned;
<li> <strong >PtrIter &operator++()</strong>:<br/>
the iterator is (pre)incremented to the next position;
<li> <strong >bool operator==(PtrIter const &other) const</strong>:<br/>
<em >true</em> is returned if the two iterators are equal;
<li> <strong >bool operator!=(PtrIter const &other) const</strong>:<br/>
<em >true</em> is returned if the two iterators are unequal;
</ul>
The copy and move assignment operators are available.
<p>
<h2 >DEFINED TYPE</h2>
<em >PtrIter</em> defines the following type:
<ul>
<li> <strong >typedef decltype(&*Iterator()) PtrType</strong>:<br/>
</ul>
<p>
<h2 >MEMBER FUNCTIONS</h2>
All members of <em >std::iterator<std:::input_iterator_tag, ...></em> are
available, as <strong >FBB::PtrIter</strong> inherits from this class.
<p>
<h2 >EXAMPLE</h2>
<pre >
#include <algorithm>
#include <unordered_map>
#include <vector>
#include <cstring>
#include <iostream>
#include <bobcat/ptriter>
using namespace std;
using namespace FBB;
int main()
{
cout << "Enter lines, the first word will be the map's key; "
"^D when done.\n";
string key;
string line;
unordered_map<string, string> map;
while (cin >> key && getline(cin, line)) // fill the map
map[key] = line;
cout << '\n';
// initialize a support
vector<decltype(&*map.begin())> // vector, using ptrIter
support(ptrIter(map.begin()), ptrIter(map.end()));
// sort 'support'
typedef unordered_map<string, string>::value_type VT;
sort(support.begin(), support.end(),
[&](VT const *p1, VT const *p2)
{
return strcasecmp(p1->first.c_str(), p2->first.c_str()) < 0;
}
);
for(auto &element: support) // display sorted by key
cout << element->first << ' ' << element->second << '\n';
}
</pre>
<p>
<h2 >FILES</h2>
<em >bobcat/ptriter</em> - defines the class interface
<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.08.02-x.dsc</em>: detached signature;
<li> <em >bobcat_4.08.02-x.tar.gz</em>: source archive;
<li> <em >bobcat_4.08.02-x_i386.changes</em>: change log;
<li> <em >libbobcat1_4.08.02-x_*.deb</em>: debian package holding the
libraries;
<li> <em >libbobcat1-dev_4.08.02-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>
</body>
</html>
|