3 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4 <title>set_intersection</title>
5 <link rel="stylesheet" href="../../../../../../../../doc/src/boostbook.css" type="text/css">
6 <meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
7 <link rel="home" href="../../../../index.html" title="Chapter 1. Range 2.0">
8 <link rel="up" href="../set.html" title="Set algorithms">
9 <link rel="prev" href="set_union.html" title="set_union">
10 <link rel="next" href="set_difference.html" title="set_difference">
12 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13 <table cellpadding="2" width="100%"><tr>
14 <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../../boost.png"></td>
15 <td align="center"><a href="../../../../../../../../index.html">Home</a></td>
16 <td align="center"><a href="../../../../../../../../libs/libraries.htm">Libraries</a></td>
17 <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
18 <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
19 <td align="center"><a href="../../../../../../../../more/index.htm">More</a></td>
22 <div class="spirit-nav">
23 <a accesskey="p" href="set_union.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../set.html"><img src="../../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../../index.html"><img src="../../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="set_difference.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
26 <div class="titlepage"><div><div><h5 class="title">
27 <a name="range.reference.algorithms.set.set_intersection"></a><a class="link" href="set_intersection.html" title="set_intersection">set_intersection</a>
28 </h5></div></div></div>
30 <a name="range.reference.algorithms.set.set_intersection.h0"></a>
31 <span class="phrase"><a name="range.reference.algorithms.set.set_intersection.prototype"></a></span><a class="link" href="set_intersection.html#range.reference.algorithms.set.set_intersection.prototype">Prototype</a>
35 <pre class="programlisting"><span class="keyword">template</span><span class="special"><</span>
36 <span class="keyword">class</span> <span class="identifier">SinglePassRange1</span><span class="special">,</span>
37 <span class="keyword">class</span> <span class="identifier">SinglePassRange2</span><span class="special">,</span>
38 <span class="keyword">class</span> <span class="identifier">OutputIterator</span>
39 <span class="special">></span>
40 <span class="identifier">OutputIterator</span> <span class="identifier">set_intersection</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">SinglePassRange1</span><span class="special">&</span> <span class="identifier">rng1</span><span class="special">,</span>
41 <span class="keyword">const</span> <span class="identifier">SinglePassRange2</span><span class="special">&</span> <span class="identifier">rng2</span><span class="special">,</span>
42 <span class="identifier">OutputIterator</span> <span class="identifier">out</span><span class="special">);</span>
44 <span class="keyword">template</span><span class="special"><</span>
45 <span class="keyword">class</span> <span class="identifier">SinglePassRange1</span><span class="special">,</span>
46 <span class="keyword">class</span> <span class="identifier">SinglePassRange2</span><span class="special">,</span>
47 <span class="keyword">class</span> <span class="identifier">OutputIterator</span><span class="special">,</span>
48 <span class="keyword">class</span> <span class="identifier">BinaryPredicate</span>
49 <span class="special">></span>
50 <span class="identifier">OutputIterator</span> <span class="identifier">set_intersection</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">SinglePassRange1</span><span class="special">&</span> <span class="identifier">rng1</span><span class="special">,</span>
51 <span class="keyword">const</span> <span class="identifier">SinglePassRange2</span><span class="special">&</span> <span class="identifier">rng2</span><span class="special">,</span>
52 <span class="identifier">OutputIterator</span> <span class="identifier">out</span><span class="special">,</span>
53 <span class="identifier">BinaryPredicate</span> <span class="identifier">pred</span><span class="special">);</span>
58 <a name="range.reference.algorithms.set.set_intersection.h1"></a>
59 <span class="phrase"><a name="range.reference.algorithms.set.set_intersection.description"></a></span><a class="link" href="set_intersection.html#range.reference.algorithms.set.set_intersection.description">Description</a>
62 <code class="computeroutput"><span class="identifier">set_intersection</span></code> constructs
63 a sorted range that is the intersection of the sorted ranges <code class="computeroutput"><span class="identifier">rng1</span></code> and <code class="computeroutput"><span class="identifier">rng2</span></code>.
64 The return value is the end of the output range.
67 The ordering relationship is determined by using <code class="computeroutput"><span class="keyword">operator</span><span class="special"><</span></code> in the non-predicate versions, and
68 by evaluating <code class="computeroutput"><span class="identifier">pred</span></code> in
69 the predicate versions.
72 <a name="range.reference.algorithms.set.set_intersection.h2"></a>
73 <span class="phrase"><a name="range.reference.algorithms.set.set_intersection.definition"></a></span><a class="link" href="set_intersection.html#range.reference.algorithms.set.set_intersection.definition">Definition</a>
76 Defined in the header file <code class="computeroutput"><span class="identifier">boost</span><span class="special">/</span><span class="identifier">range</span><span class="special">/</span><span class="identifier">algorithm</span><span class="special">/</span><span class="identifier">set_algorithm</span><span class="special">.</span><span class="identifier">hpp</span></code>
79 <a name="range.reference.algorithms.set.set_intersection.h3"></a>
80 <span class="phrase"><a name="range.reference.algorithms.set.set_intersection.requirements"></a></span><a class="link" href="set_intersection.html#range.reference.algorithms.set.set_intersection.requirements">Requirements</a>
83 <span class="bold"><strong>For the non-predicate versions:</strong></span>
85 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
87 <code class="computeroutput"><span class="identifier">SinglePassRange1</span></code>
88 is a model of the <a class="link" href="../../../concepts/single_pass_range.html" title="Single Pass Range">Single
89 Pass Range</a> Concept.
92 <code class="computeroutput"><span class="identifier">SinglePassRange2</span></code>
93 is a model of the <a class="link" href="../../../concepts/single_pass_range.html" title="Single Pass Range">Single
94 Pass Range</a> Concept.
97 <code class="computeroutput"><span class="identifier">OutputIterator</span></code> is
98 a model of the <code class="computeroutput"><span class="identifier">OutputIteratorConcept</span></code>.
100 <li class="listitem">
101 <code class="computeroutput"><span class="identifier">SinglePassRange1</span></code>
102 and <code class="computeroutput"><span class="identifier">SinglePassRange2</span></code>
103 have the same value type.
105 <li class="listitem">
106 <code class="computeroutput"><span class="identifier">SinglePassRange1</span></code>'s
107 value type is a model of the <code class="computeroutput"><span class="identifier">LessThanComparableConcept</span></code>.
109 <li class="listitem">
110 <code class="computeroutput"><span class="identifier">SinglePassRange2</span></code>'s
111 value type is a model of the <code class="computeroutput"><span class="identifier">LessThanComparableConcept</span></code>.
113 <li class="listitem">
114 The ordering of objects of type <code class="computeroutput"><span class="identifier">SinglePassRange1</span></code>'s
115 value type is a <span class="bold"><strong><span class="emphasis"><em>strict weak ordering</em></span></strong></span>,
116 as defined in the <code class="computeroutput"><span class="identifier">LessThanComparableConcept</span></code>
119 <li class="listitem">
120 The ordering of objects of type <code class="computeroutput"><span class="identifier">SinglePassRange2</span></code>'s
121 value type is a <span class="bold"><strong><span class="emphasis"><em>strict weak ordering</em></span></strong></span>,
122 as defined in the <code class="computeroutput"><span class="identifier">LessThanComparableConcept</span></code>
127 <span class="bold"><strong>For the predicate versions:</strong></span>
129 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
130 <li class="listitem">
131 <code class="computeroutput"><span class="identifier">SinglePassRange1</span></code>
132 is a model of the <a class="link" href="../../../concepts/single_pass_range.html" title="Single Pass Range">Single
133 Pass Range</a> Concept.
135 <li class="listitem">
136 <code class="computeroutput"><span class="identifier">SinglePassRange2</span></code>
137 is a model of the <a class="link" href="../../../concepts/single_pass_range.html" title="Single Pass Range">Single
138 Pass Range</a> Concept.
140 <li class="listitem">
141 <code class="computeroutput"><span class="identifier">OutputIterator</span></code> is
142 a model of the <code class="computeroutput"><span class="identifier">OutputIteratorConcept</span></code>.
144 <li class="listitem">
145 <code class="computeroutput"><span class="identifier">SinglePassRange1</span></code>
146 and <code class="computeroutput"><span class="identifier">SinglePassRange2</span></code>
147 have the same value type.
149 <li class="listitem">
150 <code class="computeroutput"><span class="identifier">BinaryPredicate</span></code> is
151 a model of the <code class="computeroutput"><span class="identifier">StrictWeakOrderingConcept</span></code>.
153 <li class="listitem">
154 <code class="computeroutput"><span class="identifier">SinglePassRange1</span></code>'s
155 value type is convertible to <code class="computeroutput"><span class="identifier">BinaryPredicate</span></code>'s
158 <li class="listitem">
159 <code class="computeroutput"><span class="identifier">SinglePassRange2</span></code>'s
160 value type is convertible to <code class="computeroutput"><span class="identifier">BinaryPredicate</span></code>'s
161 second argument types.
165 <a name="range.reference.algorithms.set.set_intersection.h4"></a>
166 <span class="phrase"><a name="range.reference.algorithms.set.set_intersection.precondition_"></a></span><a class="link" href="set_intersection.html#range.reference.algorithms.set.set_intersection.precondition_">Precondition:</a>
169 <span class="bold"><strong>For the non-predicate versions:</strong></span>
172 <code class="computeroutput"><span class="identifier">rng1</span></code> and <code class="computeroutput"><span class="identifier">rng2</span></code> are sorted in ascending order
173 according to <code class="computeroutput"><span class="keyword">operator</span><span class="special"><</span></code>.
176 <span class="bold"><strong>For the predicate versions:</strong></span>
179 <code class="computeroutput"><span class="identifier">rng1</span></code> and <code class="computeroutput"><span class="identifier">rng2</span></code> are sorted in ascending order
180 according to <code class="computeroutput"><span class="identifier">pred</span></code>.
183 <a name="range.reference.algorithms.set.set_intersection.h5"></a>
184 <span class="phrase"><a name="range.reference.algorithms.set.set_intersection.complexity"></a></span><a class="link" href="set_intersection.html#range.reference.algorithms.set.set_intersection.complexity">Complexity</a>
187 Linear. <code class="computeroutput"><span class="identifier">O</span><span class="special">(</span><span class="identifier">N</span><span class="special">)</span></code>,
188 where <code class="computeroutput"><span class="identifier">N</span></code> is <code class="computeroutput"><span class="identifier">distance</span><span class="special">(</span><span class="identifier">rng1</span><span class="special">)</span> <span class="special">+</span> <span class="identifier">distance</span><span class="special">(</span><span class="identifier">rng2</span><span class="special">)</span></code>.
191 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
192 <td align="left"></td>
193 <td align="right"><div class="copyright-footer">Copyright © 2003-2010 Thorsten Ottosen,
195 Distributed under the Boost Software License, Version 1.0. (See accompanying
196 file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
201 <div class="spirit-nav">
202 <a accesskey="p" href="set_union.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../set.html"><img src="../../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../../index.html"><img src="../../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="set_difference.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>