1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>set_union</title> 5<link rel="stylesheet" href="../../../../../../../../doc/src/boostbook.css" type="text/css"> 6<meta name="generator" content="DocBook XSL Stylesheets V1.79.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="includes.html" title="includes"> 10<link rel="next" href="set_intersection.html" title="set_intersection"> 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="includes.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_intersection.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_union"></a><a class="link" href="set_union.html" title="set_union">set_union</a> 28</h5></div></div></div> 29<h6> 30<a name="range.reference.algorithms.set.set_union.h0"></a> 31 <span class="phrase"><a name="range.reference.algorithms.set.set_union.prototype"></a></span><a class="link" href="set_union.html#range.reference.algorithms.set.set_union.prototype">Prototype</a> 32 </h6> 33<p> 34</p> 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_union</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> 43 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_union</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> 54</pre> 55<p> 56 </p> 57<h6> 58<a name="range.reference.algorithms.set.set_union.h1"></a> 59 <span class="phrase"><a name="range.reference.algorithms.set.set_union.description"></a></span><a class="link" href="set_union.html#range.reference.algorithms.set.set_union.description">Description</a> 60 </h6> 61<p> 62 <code class="computeroutput"><span class="identifier">set_union</span></code> constructs 63 a sorted range that is the union of the sorted ranges <code class="computeroutput"><span class="identifier">rng1</span></code> 64 and <code class="computeroutput"><span class="identifier">rng2</span></code>. The return 65 value is the end of the output range. The ordering relationship is determined 66 by using <code class="computeroutput"><span class="keyword">operator</span><span class="special"><</span></code> 67 in the non-predicate versions, and by evaluating <code class="computeroutput"><span class="identifier">pred</span></code> 68 in the predicate versions. 69 </p> 70<h6> 71<a name="range.reference.algorithms.set.set_union.h2"></a> 72 <span class="phrase"><a name="range.reference.algorithms.set.set_union.definition"></a></span><a class="link" href="set_union.html#range.reference.algorithms.set.set_union.definition">Definition</a> 73 </h6> 74<p> 75 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> 76 </p> 77<h6> 78<a name="range.reference.algorithms.set.set_union.h3"></a> 79 <span class="phrase"><a name="range.reference.algorithms.set.set_union.requirements"></a></span><a class="link" href="set_union.html#range.reference.algorithms.set.set_union.requirements">Requirements</a> 80 </h6> 81<p> 82 <span class="bold"><strong>For the non-predicate versions:</strong></span> 83 </p> 84<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 85<li class="listitem"> 86 <code class="computeroutput"><span class="identifier">SinglePassRange1</span></code> 87 is a model of the <a class="link" href="../../../concepts/single_pass_range.html" title="Single Pass Range">Single 88 Pass Range</a> Concept. 89 </li> 90<li class="listitem"> 91 <code class="computeroutput"><span class="identifier">SinglePassRange2</span></code> 92 is a model of the <a class="link" href="../../../concepts/single_pass_range.html" title="Single Pass Range">Single 93 Pass Range</a> Concept. 94 </li> 95<li class="listitem"> 96 <code class="computeroutput"><span class="identifier">OutputIterator</span></code> is 97 a model of the <code class="computeroutput"><span class="identifier">OutputIteratorConcept</span></code>. 98 </li> 99<li class="listitem"> 100 <code class="computeroutput"><span class="identifier">SinglePassRange1</span></code> 101 and <code class="computeroutput"><span class="identifier">SinglePassRange2</span></code> 102 have the same value type. 103 </li> 104<li class="listitem"> 105 <code class="computeroutput"><span class="identifier">SinglePassRange1</span></code>'s 106 value type is a model of the <code class="computeroutput"><span class="identifier">LessThanComparableConcept</span></code>. 107 </li> 108<li class="listitem"> 109 <code class="computeroutput"><span class="identifier">SinglePassRange2</span></code>'s 110 value type is a model of the <code class="computeroutput"><span class="identifier">LessThanComparableConcept</span></code>. 111 </li> 112<li class="listitem"> 113 The ordering of objects of type <code class="computeroutput"><span class="identifier">SinglePassRange1</span></code>'s 114 value type is a <span class="bold"><strong><span class="emphasis"><em>strict weak ordering</em></span></strong></span>, 115 as defined in the <code class="computeroutput"><span class="identifier">LessThanComparableConcept</span></code> 116 requirements. 117 </li> 118<li class="listitem"> 119 The ordering of objects of type <code class="computeroutput"><span class="identifier">SinglePassRange2</span></code>'s 120 value type is a <span class="bold"><strong><span class="emphasis"><em>strict weak ordering</em></span></strong></span>, 121 as defined in the <code class="computeroutput"><span class="identifier">LessThanComparableConcept</span></code> 122 requirements. 123 </li> 124</ul></div> 125<p> 126 <span class="bold"><strong>For the predicate versions:</strong></span> 127 </p> 128<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 129<li class="listitem"> 130 <code class="computeroutput"><span class="identifier">SinglePassRange1</span></code> 131 is a model of the <a class="link" href="../../../concepts/single_pass_range.html" title="Single Pass Range">Single 132 Pass Range</a> Concept. 133 </li> 134<li class="listitem"> 135 <code class="computeroutput"><span class="identifier">SinglePassRange2</span></code> 136 is a model of the <a class="link" href="../../../concepts/single_pass_range.html" title="Single Pass Range">Single 137 Pass Range</a> Concept. 138 </li> 139<li class="listitem"> 140 <code class="computeroutput"><span class="identifier">OutputIterator</span></code> is 141 a model of the <code class="computeroutput"><span class="identifier">OutputIteratorConcept</span></code>. 142 </li> 143<li class="listitem"> 144 <code class="computeroutput"><span class="identifier">SinglePassRange1</span></code> 145 and <code class="computeroutput"><span class="identifier">SinglePassRange2</span></code> 146 have the same value type. 147 </li> 148<li class="listitem"> 149 <code class="computeroutput"><span class="identifier">BinaryPredicate</span></code> is 150 a model of the <code class="computeroutput"><span class="identifier">StrictWeakOrderingConcept</span></code>. 151 </li> 152<li class="listitem"> 153 <code class="computeroutput"><span class="identifier">SinglePassRange1</span></code>'s 154 value type is convertible to <code class="computeroutput"><span class="identifier">BinaryPredicate</span></code>'s 155 first argument type. 156 </li> 157<li class="listitem"> 158 <code class="computeroutput"><span class="identifier">SinglePassRange2</span></code>'s 159 value type is convertible to <code class="computeroutput"><span class="identifier">BinaryPredicate</span></code>'s 160 second argument types. 161 </li> 162</ul></div> 163<h6> 164<a name="range.reference.algorithms.set.set_union.h4"></a> 165 <span class="phrase"><a name="range.reference.algorithms.set.set_union.precondition_"></a></span><a class="link" href="set_union.html#range.reference.algorithms.set.set_union.precondition_">Precondition:</a> 166 </h6> 167<p> 168 <span class="bold"><strong>For the non-predicate versions:</strong></span> 169 </p> 170<p> 171 <code class="computeroutput"><span class="identifier">rng1</span></code> and <code class="computeroutput"><span class="identifier">rng2</span></code> are sorted in ascending order 172 according to <code class="computeroutput"><span class="keyword">operator</span><span class="special"><</span></code>. 173 </p> 174<p> 175 <span class="bold"><strong>For the predicate versions:</strong></span> 176 </p> 177<p> 178 <code class="computeroutput"><span class="identifier">rng1</span></code> and <code class="computeroutput"><span class="identifier">rng2</span></code> are sorted in ascending order 179 according to <code class="computeroutput"><span class="identifier">pred</span></code>. 180 </p> 181<h6> 182<a name="range.reference.algorithms.set.set_union.h5"></a> 183 <span class="phrase"><a name="range.reference.algorithms.set.set_union.complexity"></a></span><a class="link" href="set_union.html#range.reference.algorithms.set.set_union.complexity">Complexity</a> 184 </h6> 185<p> 186 Linear. <code class="computeroutput"><span class="identifier">O</span><span class="special">(</span><span class="identifier">N</span><span class="special">)</span></code>, 187 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>. 188 </p> 189</div> 190<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 191<td align="left"></td> 192<td align="right"><div class="copyright-footer">Copyright © 2003-2010 Thorsten Ottosen, 193 Neil Groves<p> 194 Distributed under the Boost Software License, Version 1.0. (See accompanying 195 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>) 196 </p> 197</div></td> 198</tr></table> 199<hr> 200<div class="spirit-nav"> 201<a accesskey="p" href="includes.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_intersection.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a> 202</div> 203</body> 204</html> 205