1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>is_sorted</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="../new.html" title="New algorithms"> 9<link rel="prev" href="iota.html" title="iota"> 10<link rel="next" href="overwrite.html" title="overwrite"> 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="iota.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../new.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="overwrite.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.new.is_sorted"></a><a class="link" href="is_sorted.html" title="is_sorted">is_sorted</a> 28</h5></div></div></div> 29<h6> 30<a name="range.reference.algorithms.new.is_sorted.h0"></a> 31 <span class="phrase"><a name="range.reference.algorithms.new.is_sorted.prototype"></a></span><a class="link" href="is_sorted.html#range.reference.algorithms.new.is_sorted.prototype">Prototype</a> 32 </h6> 33<p> 34</p> 35<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">SinglePassRange</span><span class="special">></span> 36<span class="keyword">bool</span> <span class="identifier">is_sorted</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">SinglePassRange</span><span class="special">&</span> <span class="identifier">rng</span><span class="special">);</span> 37 38<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">SinglePassRange</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">BinaryPredicate</span><span class="special">></span> 39<span class="keyword">bool</span> <span class="identifier">is_sorted</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">SinglePassRange</span><span class="special">&</span> <span class="identifier">rng</span><span class="special">,</span> <span class="identifier">BinaryPredicate</span> <span class="identifier">pred</span><span class="special">);</span> 40</pre> 41<p> 42 </p> 43<h6> 44<a name="range.reference.algorithms.new.is_sorted.h1"></a> 45 <span class="phrase"><a name="range.reference.algorithms.new.is_sorted.description"></a></span><a class="link" href="is_sorted.html#range.reference.algorithms.new.is_sorted.description">Description</a> 46 </h6> 47<p> 48 <code class="computeroutput"><span class="identifier">is_sorted</span></code> determines 49 if a range is sorted. For the non-predicate version the return value 50 is <code class="computeroutput"><span class="keyword">true</span></code> if and only if for 51 each adjacent elements <code class="computeroutput"><span class="special">[</span><span class="identifier">x</span><span class="special">,</span><span class="identifier">y</span><span class="special">]</span></code> 52 the expression <code class="computeroutput"><span class="identifier">x</span> <span class="special"><</span> 53 <span class="identifier">y</span></code> is <code class="computeroutput"><span class="keyword">true</span></code>. 54 For the predicate version the return value is <code class="computeroutput"><span class="keyword">true</span></code> 55 is and only if for each adjacent elements <code class="computeroutput"><span class="special">[</span><span class="identifier">x</span><span class="special">,</span><span class="identifier">y</span><span class="special">]</span></code> 56 the expression <code class="computeroutput"><span class="identifier">pred</span><span class="special">(</span><span class="identifier">x</span><span class="special">,</span><span class="identifier">y</span><span class="special">)</span></code> 57 is <code class="computeroutput"><span class="keyword">true</span></code>. 58 </p> 59<h6> 60<a name="range.reference.algorithms.new.is_sorted.h2"></a> 61 <span class="phrase"><a name="range.reference.algorithms.new.is_sorted.definition"></a></span><a class="link" href="is_sorted.html#range.reference.algorithms.new.is_sorted.definition">Definition</a> 62 </h6> 63<p> 64 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_ext</span><span class="special">/</span><span class="identifier">is_sorted</span><span class="special">.</span><span class="identifier">hpp</span></code> 65 </p> 66<h6> 67<a name="range.reference.algorithms.new.is_sorted.h3"></a> 68 <span class="phrase"><a name="range.reference.algorithms.new.is_sorted.requirements"></a></span><a class="link" href="is_sorted.html#range.reference.algorithms.new.is_sorted.requirements">Requirements</a> 69 </h6> 70<div class="orderedlist"><ol class="orderedlist" type="1"> 71<li class="listitem"> 72 <code class="computeroutput"><span class="identifier">SinglePassRange</span></code> is 73 a model of the <a class="link" href="../../../concepts/single_pass_range.html" title="Single Pass Range">Single 74 Pass Range</a> Concept. 75 </li> 76<li class="listitem"> 77 <code class="computeroutput"><span class="identifier">BinaryPredicate</span></code> is 78 a model of the <code class="computeroutput"><span class="identifier">BinaryPredicate</span></code> 79 Concept. 80 </li> 81<li class="listitem"> 82 The value type of <code class="computeroutput"><span class="identifier">SinglePassRange</span></code> 83 is convertible to both argument types of <code class="computeroutput"><span class="identifier">BinaryPredicate</span></code>. 84 </li> 85</ol></div> 86<h6> 87<a name="range.reference.algorithms.new.is_sorted.h4"></a> 88 <span class="phrase"><a name="range.reference.algorithms.new.is_sorted.complexity"></a></span><a class="link" href="is_sorted.html#range.reference.algorithms.new.is_sorted.complexity">Complexity</a> 89 </h6> 90<p> 91 Linear. A maximum of <code class="computeroutput"><span class="identifier">distance</span><span class="special">(</span><span class="identifier">rng</span><span class="special">)</span></code> comparisons are performed. 92 </p> 93</div> 94<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 95<td align="left"></td> 96<td align="right"><div class="copyright-footer">Copyright © 2003-2010 Thorsten Ottosen, 97 Neil Groves<p> 98 Distributed under the Boost Software License, Version 1.0. (See accompanying 99 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>) 100 </p> 101</div></td> 102</tr></table> 103<hr> 104<div class="spirit-nav"> 105<a accesskey="p" href="iota.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../new.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="overwrite.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a> 106</div> 107</body> 108</html> 109