forked from boostorg/range
96 lines
2.1 KiB
HTML
Executable File
96 lines
2.1 KiB
HTML
Executable File
<!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="uniqued"></a>
|
|
<h4><code>uniqued</code></h4>
|
|
<blockquote>
|
|
<pre>rng | boost::adaptors::uniqued</pre>
|
|
<pre>boost::make_uniqued_range( rng )</pre>
|
|
</blockquote>
|
|
<ul>
|
|
<li>
|
|
<b>Precondition:</b>
|
|
The value-type of the range is comparable with
|
|
<code>operator==()</code>.
|
|
</li>
|
|
<li>
|
|
<b>Postcondition:</b>
|
|
For all adjacent elements <code>[x,y]</code> in the returned range,
|
|
<code>x==y</code> is false.
|
|
</li>
|
|
<li>
|
|
<b>Range Category:</b>
|
|
ForwardRange
|
|
</li>
|
|
</ul>
|
|
|
|
<hr />
|
|
<h3>Example</h3>
|
|
|
|
<pre>
|
|
#include <boost/range/adaptor/uniqued.hpp>
|
|
#include <boost/range/algorithm/copy.hpp>
|
|
#include <boost/assign.hpp>
|
|
#include <algorithm>
|
|
#include <iostream>
|
|
#include <vector>
|
|
|
|
int main(int argc, const char* argv)
|
|
{
|
|
using namespace boost::assign;
|
|
using namespace boost::adaptors;
|
|
|
|
std::vector<int> input;
|
|
input += 1,1,2,2,2,3,4,5,6;
|
|
|
|
boost::copy(
|
|
input | uniqued,
|
|
std::ostream_iterator<int>(std::cout, ",") );
|
|
|
|
return 0;
|
|
}
|
|
</pre>
|
|
<p>
|
|
This would produce the output:<br />
|
|
<code>1,2,3,4,5,6</code><br />
|
|
</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>
|
|
|