2000-04-22 04:33:34 +08:00
|
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
|
|
|
|
<HTML>
|
|
|
|
<HEAD>
|
|
|
|
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
|
2000-07-12 05:45:08 +08:00
|
|
|
<META NAME="AUTHOR" CONTENT="pme@sources.redhat.com (Phil Edwards)">
|
configopts.html, [...]: Remove many EGCS references...
* docs/configopts.html, docs/install.html, docs/17_intro/BADNAMES,
docs/17_intro/howto.html, docs/18_support/howto.html,
docs/19_diagnostics/howto.html, docs/20_util/howto.html,
docs/21_strings/howto.html, docs/22_locale/howto.html,
docs/23_containers/howto.html, docs/24_iterators/howto.html,
docs/25_algorithms/howto.html, docs/26_numerics/howto.html,
docs/27_io/howto.html, docs/ext/howto.html, docs/faq/index.html:
Remove many EGCS references; use current absolute URLs on
gcc.gnu.org or sources.redhat.com for messages in list archives.
* docs/faq/index.txt: Regenerate.
From-SVN: r36988
2000-10-21 08:51:50 +08:00
|
|
|
<META NAME="KEYWORDS" CONTENT="HOWTO, libstdc++, GCC, g++, libg++, STL">
|
2000-04-22 04:33:34 +08:00
|
|
|
<META NAME="DESCRIPTION" CONTENT="HOWTO for the libstdc++ chapter 25.">
|
|
|
|
<META NAME="GENERATOR" CONTENT="vi and eight fingers">
|
|
|
|
<TITLE>libstdc++-v3 HOWTO: Chapter 25</TITLE>
|
2000-07-12 05:45:08 +08:00
|
|
|
<LINK REL="home" HREF="http://sources.redhat.com/libstdc++/docs/25_algorithms/">
|
2000-04-22 04:33:34 +08:00
|
|
|
<LINK REL=StyleSheet HREF="../lib3styles.css">
|
configopts.html, [...]: Remove many EGCS references...
* docs/configopts.html, docs/install.html, docs/17_intro/BADNAMES,
docs/17_intro/howto.html, docs/18_support/howto.html,
docs/19_diagnostics/howto.html, docs/20_util/howto.html,
docs/21_strings/howto.html, docs/22_locale/howto.html,
docs/23_containers/howto.html, docs/24_iterators/howto.html,
docs/25_algorithms/howto.html, docs/26_numerics/howto.html,
docs/27_io/howto.html, docs/ext/howto.html, docs/faq/index.html:
Remove many EGCS references; use current absolute URLs on
gcc.gnu.org or sources.redhat.com for messages in list archives.
* docs/faq/index.txt: Regenerate.
From-SVN: r36988
2000-10-21 08:51:50 +08:00
|
|
|
<!-- $Id: howto.html,v 1.3 2000/07/11 21:45:08 pme Exp $ -->
|
2000-04-22 04:33:34 +08:00
|
|
|
</HEAD>
|
|
|
|
<BODY>
|
|
|
|
|
|
|
|
<H1 CLASS="centered"><A NAME="top">Chapter 25: Algorithms</A></H1>
|
|
|
|
|
2000-07-08 05:13:28 +08:00
|
|
|
<P>Chapter 25 deals with the generalized subroutines for automatically
|
2000-04-22 04:33:34 +08:00
|
|
|
transforming lemmings into gold.
|
|
|
|
</P>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ####################################################### -->
|
|
|
|
<HR>
|
|
|
|
<H1>Contents</H1>
|
|
|
|
<UL>
|
2000-07-08 05:13:28 +08:00
|
|
|
<LI><A HREF="#1">Prerequisites</A>
|
2000-04-22 04:33:34 +08:00
|
|
|
<LI><A HREF="#2">Topic</A>
|
|
|
|
</UL>
|
|
|
|
|
|
|
|
<HR>
|
|
|
|
|
|
|
|
<!-- ####################################################### -->
|
|
|
|
|
2000-07-08 05:13:28 +08:00
|
|
|
<H2><A NAME="1">Prerequisites</A></H2>
|
|
|
|
<P>The neatest accomplishment of the algorithms chapter is that all the
|
|
|
|
work is done via iterators, not containers directly. This means two
|
|
|
|
important things:
|
|
|
|
<OL>
|
|
|
|
<LI>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. So do your own iterators.
|
|
|
|
<LI>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.
|
|
|
|
</OL>
|
|
|
|
</P>
|
|
|
|
<P>Even strings can be fed through the algorithms here, although the
|
|
|
|
string class has specialized versions of many of these functions (for
|
|
|
|
example, <TT>string::find()</TT>). Most of the examples on this
|
|
|
|
page will use simple arrays of integers as a playground for
|
|
|
|
algorithms, just to keep things simple.
|
|
|
|
<A NAME="Nsize">The use of <B>N</B></A> as a size in the examples is
|
|
|
|
to keep things easy to read but probably won't be legal code. You can
|
|
|
|
use wrappers such as those described in the
|
|
|
|
<A HREF="../23_containers/howto.html">containers chapter</A> to keep
|
|
|
|
real code readable.
|
|
|
|
</P>
|
|
|
|
<P>The single thing that trips people up the most is the definition of
|
|
|
|
<EM>range</EM> used with iterators; the famous
|
|
|
|
"past-the-end" rule that everybody loves to hate. The
|
|
|
|
<A HREF="../24_iterators/howto.html">iterators chapter</A> of this
|
|
|
|
document has a complete explanation of this simple rule that seems to
|
|
|
|
cause so much confusion. Once you get <EM>range</EM> into your head
|
|
|
|
(it's not that hard, honest!), then the algorithms are a cakewalk.
|
|
|
|
</P>
|
|
|
|
<P>
|
2000-04-22 04:33:34 +08:00
|
|
|
</P>
|
|
|
|
<P>Return <A HREF="#top">to top of page</A> or
|
|
|
|
<A HREF="../faq/index.html">to the FAQ</A>.
|
|
|
|
</P>
|
|
|
|
|
|
|
|
<HR>
|
|
|
|
<H2><A NAME="2">Topic</A></H2>
|
|
|
|
<P>Blah.
|
|
|
|
</P>
|
|
|
|
<P>Return <A HREF="#top">to top of page</A> or
|
|
|
|
<A HREF="../faq/index.html">to the FAQ</A>.
|
|
|
|
</P>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ####################################################### -->
|
|
|
|
|
|
|
|
<HR>
|
|
|
|
<P CLASS="fineprint"><EM>
|
|
|
|
Comments and suggestions are welcome, and may be sent to
|
2000-07-12 05:45:08 +08:00
|
|
|
<A HREF="mailto:pme@sources.redhat.com">Phil Edwards</A> or
|
configopts.html, [...]: Remove many EGCS references...
* docs/configopts.html, docs/install.html, docs/17_intro/BADNAMES,
docs/17_intro/howto.html, docs/18_support/howto.html,
docs/19_diagnostics/howto.html, docs/20_util/howto.html,
docs/21_strings/howto.html, docs/22_locale/howto.html,
docs/23_containers/howto.html, docs/24_iterators/howto.html,
docs/25_algorithms/howto.html, docs/26_numerics/howto.html,
docs/27_io/howto.html, docs/ext/howto.html, docs/faq/index.html:
Remove many EGCS references; use current absolute URLs on
gcc.gnu.org or sources.redhat.com for messages in list archives.
* docs/faq/index.txt: Regenerate.
From-SVN: r36988
2000-10-21 08:51:50 +08:00
|
|
|
<A HREF="mailto:gdr@gcc.gnu.org">Gabriel Dos Reis</A>.
|
|
|
|
<BR> $Id: howto.html,v 1.3 2000/07/11 21:45:08 pme Exp $
|
2000-04-22 04:33:34 +08:00
|
|
|
</EM></P>
|
|
|
|
|
|
|
|
|
|
|
|
</BODY>
|
|
|
|
</HTML>
|