Files
boost_range/doc/style.html

118 lines
3.3 KiB
HTML
Raw Normal View History

2004-07-30 02:56:01 +00:00
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
2004-08-05 19:37:40 +00:00
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Boost.Range Terminology and Style Guidelines </title>
<link rel="stylesheet" href="style.css" type="text/css">
2004-07-30 02:56:01 +00:00
</head>
2004-08-05 19:37:40 +00:00
<body>
<table border="0" >
<tr>
<td ><img src="cboost.gif" border="0" ></td>
2004-08-10 09:56:55 +00:00
<td ><h1 align="center">Boost.Range </h1></td>
</tr>
2004-08-05 19:37:40 +00:00
</table>
<h2>Terminology and style guidelines </h2>
2004-08-10 09:56:55 +00:00
2004-08-05 19:37:40 +00:00
<p>
2004-08-10 09:56:55 +00:00
The use of a consistent terminology is as important for <a href="range.html#range">Range</a>s
and range-based algorithms as it is for iterators and iterator-based algorithms.
If a conventional set of names are adopted, we can avoid misunderstandings and
write generic function prototypes that are <i>self-documenting</i>.
2004-08-05 19:37:40 +00:00
</p>
<p>
2004-08-10 09:56:55 +00:00
Since ranges are characterized by a specific underlying iterator type, we get a
type of range for each type of iterator. Hence we can speak of the following
types of ranges:
2004-08-05 19:37:40 +00:00
<ul>
<li>
<i>Value access</i> category:
<ul>
<li>
2004-08-10 09:56:55 +00:00
Readable Range
2004-08-05 19:37:40 +00:00
<li>
2004-08-10 09:56:55 +00:00
Writeable Range
2004-08-05 19:37:40 +00:00
<li>
2004-08-10 09:56:55 +00:00
Swappable Range
2004-08-05 19:37:40 +00:00
<li>
2004-08-10 09:56:55 +00:00
Lvalue Range
2004-08-05 19:37:40 +00:00
</ul>
<li>
<i>Traversal</i> category:
<ul>
<li>
2004-08-10 09:56:55 +00:00
<a href="range.htm#single_pass_range">Single Pass Range</a>
2004-08-05 19:37:40 +00:00
<li>
2004-08-10 09:56:55 +00:00
<a href="range.htm#forward_range">Forward Range</a>
2004-08-05 19:37:40 +00:00
<li>
2004-08-10 09:56:55 +00:00
<a href="range.htm#bidirectional_range">Bidirectional Range</a>
2004-08-05 19:37:40 +00:00
<li>
2004-08-10 09:56:55 +00:00
<a href="range.htm#random_access_range">Random Access Range</a>
2004-08-05 19:37:40 +00:00
</ul>
</ul>
Notice how we have used the categories from the <a href=../../iterator/doc/new-iter-concepts.html>new
2004-08-10 09:56:55 +00:00
style iterators</a>.
2004-08-05 19:37:40 +00:00
<p>
2004-08-10 09:56:55 +00:00
Notice that an iterator (and therefore an range) has one <i>traversal</i>
2004-08-05 19:37:40 +00:00
property and one or more properties from the <i>value access</i> category. So in
2004-08-10 09:56:55 +00:00
reality we will mostly talk about mixtures such as
2004-08-05 19:37:40 +00:00
<ul>
<li>
2004-08-10 09:56:55 +00:00
Random Access Readable Writeable Range
2004-08-05 19:37:40 +00:00
<li>
2004-08-10 09:56:55 +00:00
Forward Lvalue Range
2004-08-05 19:37:40 +00:00
</ul>
2004-08-10 09:56:55 +00:00
By convention, we should always specify the <i>traversal</i> property first as
done above. This seems reasonable since there will only be one <i>traversal</i>
property, but perhaps many <i>value access</i> properties.
2004-08-05 19:37:40 +00:00
</p>
<p>
As an example, consider how we specify the interface of <code>std::sort()</code>.
The iterator-based version looks like this:
<pre>
2004-07-30 02:56:01 +00:00
template< class RandomAccessTraversalReadableWritableIterator >
void sort( RandomAccessTraversalReadableWritableIterator first,
RandomAccessTraversalReadableWritableIterator last );
</pre>
2004-08-10 09:56:55 +00:00
For ranges the interface becomes
2004-08-05 19:37:40 +00:00
<pre>
2004-07-30 02:56:01 +00:00
template< class RandomAccessReadableWritableRange >
void sort( RandomAccessReadableWritableRange& r );
</pre>
2004-08-05 19:37:40 +00:00
</p>
<hr>
<p>
2004-07-30 02:56:01 +00:00
(C) Copyright Thorsten Ottosen 2003-2004
2004-08-05 19:37:40 +00:00
</p>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
</body>
2004-07-30 02:56:01 +00:00
</html>