diff options
author | redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-04-21 23:33:44 +0000 |
---|---|---|
committer | redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-04-21 23:33:44 +0000 |
commit | bd8a9cbe3ab8a02f669adf27655c97f0f1211967 (patch) | |
tree | 80f57097da71ed324ad21f9513419c6d2b076a31 /libstdc++-v3/doc/html/manual/algorithms.html | |
parent | 5a2aecd69f9210e2b54c34d515a6db56ee070527 (diff) | |
download | ppe42-gcc-bd8a9cbe3ab8a02f669adf27655c97f0f1211967.tar.gz ppe42-gcc-bd8a9cbe3ab8a02f669adf27655c97f0f1211967.zip |
2010-04-22 Jonathan Wakely <jwakely.gcc@gmail.com>
* doc/xml/faq.xml: Link to manual.
* doc/xml/manual/using.xml: Expand dynamic libraries section.
* doc/xml/manual/strings.xml: Mention shrink_to_fit() member.
* doc/xml/manual/prerequisites.xml: Link to doxygen requirements.
* doc/xml/manual/appendix_contributing.xml: Update Bash version.
* doc/html/*: Regenerate.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158624 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/doc/html/manual/algorithms.html')
-rw-r--r-- | libstdc++-v3/doc/html/manual/algorithms.html | 60 |
1 files changed, 56 insertions, 4 deletions
diff --git a/libstdc++-v3/doc/html/manual/algorithms.html b/libstdc++-v3/doc/html/manual/algorithms.html index 6049cd8ec0e..3e5b3a5a86e 100644 --- a/libstdc++-v3/doc/html/manual/algorithms.html +++ b/libstdc++-v3/doc/html/manual/algorithms.html @@ -1,9 +1,61 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Part IX. Algorithms</title><meta name="generator" content="DocBook XSL Stylesheets V1.75.2" /><meta name="keywords" content=" ISO C++ , library , algorithm " /><link rel="home" href="../spine.html" title="The GNU C++ Library Documentation" /><link rel="up" href="spine.html" title="The GNU C++ Library" /><link rel="prev" href="bk01pt08ch19s02.html" title="One Past the End" /><link rel="next" href="bk01pt09pr02.html" title="" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Part IX. +<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Chapter 11. Algorithms</title><meta name="generator" content="DocBook XSL Stylesheets V1.75.2" /><meta name="keywords" content=" ISO C++ , library , algorithm " /><link rel="home" href="../spine.html" title="The GNU C++ Library Documentation" /><link rel="up" href="bk01pt02.html" title="Part II. Standard Contents" /><link rel="prev" href="iterators.html" title="Chapter 10. Iterators" /><link rel="next" href="numerics.html" title="Chapter 12. Numerics" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 11. Algorithms -</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="bk01pt08ch19s02.html">Prev</a> </td><th width="60%" align="center">The GNU C++ Library</th><td width="20%" align="right"> <a accesskey="n" href="bk01pt09pr02.html">Next</a></td></tr></table><hr /></div><div class="part" title="Part IX. Algorithms"><div class="titlepage"><div><div><h1 class="title"><a id="manual.algorithms"></a>Part IX. +</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="iterators.html">Prev</a> </td><th width="60%" align="center">Part II. + Standard Contents +</th><td width="20%" align="right"> <a accesskey="n" href="numerics.html">Next</a></td></tr></table><hr /></div><div class="chapter" title="Chapter 11. Algorithms"><div class="titlepage"><div><div><h2 class="title"><a id="std.algorithms"></a>Chapter 11. Algorithms - <a id="id638163" class="indexterm"></a> -</h1></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="preface"><a href="bk01pt09pr02.html"></a></span></dt><dt><span class="chapter"><a href="bk01pt09ch20.html">20. Mutating</a></span></dt><dd><dl><dt><span class="sect1"><a href="bk01pt09ch20.html#algorithms.mutating.swap"><code class="function">swap</code></a></span></dt><dd><dl><dt><span class="sect2"><a href="bk01pt09ch20.html#algorithms.swap.specializations">Specializations</a></span></dt></dl></dd></dl></dd></dl></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="bk01pt08ch19s02.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="spine.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="bk01pt09pr02.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">One Past the End </td><td width="20%" align="center"><a accesskey="h" href="../spine.html">Home</a></td><td width="40%" align="right" valign="top"> </td></tr></table></div></body></html> + <a id="id505811" class="indexterm"></a> +</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="algorithms.html#std.algorithms.mutating">Mutating</a></span></dt><dd><dl><dt><span class="sect2"><a href="algorithms.html#algorithms.mutating.swap"><code class="function">swap</code></a></span></dt></dl></dd></dl></div><p> + The neatest accomplishment of the algorithms sect1 is that all the + work is done via iterators, not containers directly. This means two + important things: +</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p> + Anything that behaves like an iterator can be used in one of + these algorithms. Raw pointers make great candidates, thus + built-in arrays are fine containers, as well as your own + iterators. + </p></li><li class="listitem"><p> + The algorithms do not (and cannot) affect the container as a + whole; only the things between the two iterator endpoints. If + you pass a range of iterators only enclosing the middle third of + a container, then anything outside that range is inviolate. + </p></li></ol></div><p> + Even strings can be fed through the algorithms here, although the + string class has specialized versions of many of these functions + (for example, <code class="code">string::find()</code>). Most of the examples + on this page will use simple arrays of integers as a playground + for algorithms, just to keep things simple. The use of + <span class="emphasis"><em>N</em></span> as a size in the examples is to keep things + easy to read but probably won't be valid code. You can use wrappers + such as those described in + the <a class="link" href="containers.html" title="Chapter 9. Containers">containers sect1</a> to keep + real code readable. +</p><p> + The single thing that trips people up the most is the definition + of <span class="emphasis"><em>range</em></span> used with iterators; the famous + "past-the-end" rule that everybody loves to hate. The + <a class="link" href="iterators.html" title="Chapter 10. Iterators">iterators sect1</a> of this + document has a complete explanation of this simple rule that seems + to cause so much confusion. Once you + get <span class="emphasis"><em>range</em></span> into your head (it's not that hard, + honest!), then the algorithms are a cakewalk. +</p><div class="sect1" title="Mutating"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="std.algorithms.mutating"></a>Mutating</h2></div></div></div><div class="sect2" title="swap"><div class="titlepage"><div><div><h3 class="title"><a id="algorithms.mutating.swap"></a><code class="function">swap</code></h3></div></div></div><div class="sect3" title="Specializations"><div class="titlepage"><div><div><h4 class="title"><a id="algorithms.swap.specializations"></a>Specializations</h4></div></div></div><p>If you call <code class="code"> std::swap(x,y); </code> where x and y are standard + containers, then the call will automatically be replaced by a call to + <code class="code"> x.swap(y); </code> instead. + </p><p>This allows member functions of each container class to take over, and + containers' swap functions should have O(1) complexity according to + the standard. (And while "should" allows implementations to + behave otherwise and remain compliant, this implementation does in + fact use constant-time swaps.) This should not be surprising, since + for two containers of the same type to swap contents, only some + internal pointers to storage need to be exchanged. + </p></div></div></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="iterators.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="bk01pt02.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="numerics.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 10. + Iterators + + </td><td width="20%" align="center"><a accesskey="h" href="../spine.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 12. + Numerics + +</td></tr></table></div></body></html> |