mirror of
https://github.com/boostorg/range.git
synced 2025-07-29 20:37:25 +02:00
Boost.RangeEx merged into Boost.Range
[SVN r60897]
This commit is contained in:
98
doc/reference/adaptors/map_values.html
Executable file
98
doc/reference/adaptors/map_values.html
Executable file
@ -0,0 +1,98 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>Boost.Range Range Adaptors </title>
|
||||
<link rel="stylesheet" href="../style.css" type="text/css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<table border="0" >
|
||||
<tr>
|
||||
<td ><img src="../../../boost.png" border="0" /></td>
|
||||
<td ><h1 align="center">Boost.Range </h1></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h2> Range Adaptors </h2>
|
||||
|
||||
<hr />
|
||||
<a name="map_values"></a>
|
||||
<h4><code>map_values</code></h4>
|
||||
<blockquote>
|
||||
<pre>rng | boost::adaptors::map_values</pre>
|
||||
<pre>boost::make_map_value_range( rng )</pre>
|
||||
</blockquote>
|
||||
<ul>
|
||||
<li>
|
||||
<b>Precondition:</b>
|
||||
The value-type of the range is an instantiation of std::pair.
|
||||
</li>
|
||||
<li>
|
||||
<b>Postcondition:</b>
|
||||
For all elements <code>x</code> in the returned range,
|
||||
<code>x</code> is the result of <code>y.second</code> where
|
||||
<code>y</code> is the corresponding element in the original range.
|
||||
</li>
|
||||
<li>
|
||||
<b>Range Category:</b>
|
||||
SinglePassRange
|
||||
</li>
|
||||
</ul>
|
||||
<hr />
|
||||
<h3>Example</h3>
|
||||
<pre>
|
||||
<span class="keyword">#include</span> <boost/range/adaptor/map.hpp>
|
||||
<span class="keyword">#include</span> <boost/range/algorithm/copy.hpp>
|
||||
<span class="keyword">#include</span> <boost/assign.hpp>
|
||||
<span class="keyword">#include</span> <algorithm>
|
||||
<span class="keyword">#include</span> <iostream>
|
||||
<span class="keyword">#include</span> <map>
|
||||
<span class="keyword">#include</span> <vector>
|
||||
|
||||
<span class="keyword">int</span> main(<span class="keyword">int</span> argc, <span class="keyword">const char</span>* argv[])
|
||||
{
|
||||
<span class="keyword">using namespace</span> boost::assign;
|
||||
<span class="keyword">using namespace</span> boost::adaptors;
|
||||
|
||||
std::map<<span class="keyword">int</span>,<span class="keyword">int</span>> input;
|
||||
<span class="keyword">for</span> (<span class="keyword">int</span> i = 0; i < 10; ++i)
|
||||
input.insert(std::make_pair(i, i * 10));
|
||||
|
||||
boost::copy(
|
||||
input | map_values,
|
||||
std::ostream_iterator<<span class="keyword">int</span>>(std::cout, ","));
|
||||
|
||||
<span class="keyword">return</span> 0;
|
||||
}
|
||||
</pre>
|
||||
<p>
|
||||
This produces the output: <br />
|
||||
<code>
|
||||
0,10,20,30,40,50,60,70,80,90
|
||||
</code>
|
||||
</p>
|
||||
|
||||
<hr />
|
||||
<p>
|
||||
(C) Copyright Neil Groves 2009
|
||||
(C) Copyright Thorsten Ottosen 2003-2004
|
||||
</p>
|
||||
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
</body>
|
||||
</html>
|
||||
|
Reference in New Issue
Block a user