Imported Upstream version 1.57.0
[platform/upstream/boost.git] / libs / range / doc / html / range / reference / algorithms / set / set_intersection.html
1 <html>
2 <head>
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&#160;1.&#160;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">
11 </head>
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>
20 </tr></table>
21 <hr>
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>
24 </div>
25 <div class="section">
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>
29 <h6>
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>
32           </h6>
33 <p>
34 </p>
35 <pre class="programlisting"><span class="keyword">template</span><span class="special">&lt;</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">&gt;</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">&amp;</span> <span class="identifier">rng1</span><span class="special">,</span>
41                                 <span class="keyword">const</span> <span class="identifier">SinglePassRange2</span><span class="special">&amp;</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>
43
44 <span class="keyword">template</span><span class="special">&lt;</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">&gt;</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">&amp;</span> <span class="identifier">rng1</span><span class="special">,</span>
51                                 <span class="keyword">const</span> <span class="identifier">SinglePassRange2</span><span class="special">&amp;</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>
54 </pre>
55 <p>
56           </p>
57 <h6>
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>
60           </h6>
61 <p>
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.
65           </p>
66 <p>
67             The ordering relationship is determined by using <code class="computeroutput"><span class="keyword">operator</span><span class="special">&lt;</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.
70           </p>
71 <h6>
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>
74           </h6>
75 <p>
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>
77           </p>
78 <h6>
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>
81           </h6>
82 <p>
83             <span class="bold"><strong>For the non-predicate versions:</strong></span>
84           </p>
85 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
86 <li class="listitem">
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.
90               </li>
91 <li class="listitem">
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.
95               </li>
96 <li class="listitem">
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>.
99               </li>
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.
104               </li>
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>.
108               </li>
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>.
112               </li>
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>
117                 requirements.
118               </li>
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>
123                 requirements.
124               </li>
125 </ul></div>
126 <p>
127             <span class="bold"><strong>For the predicate versions:</strong></span>
128           </p>
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.
134               </li>
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.
139               </li>
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>.
143               </li>
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.
148               </li>
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>.
152               </li>
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
156                 first argument type.
157               </li>
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.
162               </li>
163 </ul></div>
164 <h6>
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>
167           </h6>
168 <p>
169             <span class="bold"><strong>For the non-predicate versions:</strong></span>
170           </p>
171 <p>
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">&lt;</span></code>.
174           </p>
175 <p>
176             <span class="bold"><strong>For the predicate versions:</strong></span>
177           </p>
178 <p>
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>.
181           </p>
182 <h6>
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>
185           </h6>
186 <p>
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>.
189           </p>
190 </div>
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 &#169; 2003-2010 Thorsten Ottosen,
194       Neil Groves<p>
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>)
197       </p>
198 </div></td>
199 </tr></table>
200 <hr>
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>
203 </div>
204 </body>
205 </html>