|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r67939 - in branches/release/libs/icl: doc doc/html/boost_icl/function_reference doc/html/header/boost/icl test/test_doc_code_
From: afojgo_at_[hidden]
Date: 2011-01-10 20:00:14
Author: jofaber
Date: 2011-01-10 20:00:04 EST (Mon, 10 Jan 2011)
New Revision: 67939
URL: http://svn.boost.org/trac/boost/changeset/67939
Log:
Fixed error in docs: element_iterators are free functions. Added example and test code.
Properties modified:
branches/release/libs/icl/doc/ (props changed)
branches/release/libs/icl/doc/html/header/boost/icl/ (props changed)
branches/release/libs/icl/test/test_doc_code_/ (props changed)
Text files modified:
branches/release/libs/icl/doc/functions_element_iteration.qbk | 43 +++++++++++++++++++++++---------
branches/release/libs/icl/doc/html/boost_icl/function_reference/element_iteration.html | 52 +++++++++++++++++++++++++++++----------
branches/release/libs/icl/test/test_doc_code_/test_doc_code.cpp | 37 ++++++++++++++++++++++++++++
3 files changed, 106 insertions(+), 26 deletions(-)
Modified: branches/release/libs/icl/doc/functions_element_iteration.qbk
==============================================================================
--- branches/release/libs/icl/doc/functions_element_iteration.qbk (original)
+++ branches/release/libs/icl/doc/functions_element_iteration.qbk 2011-01-10 20:00:04 EST (Mon, 10 Jan 2011)
@@ -56,24 +56,43 @@
[table
[[['*Synopsis Complexities*]] [__ch_itv_sets__][__ch_itv_maps__]]
-[[`J T::elements_begin()`] [__O1__] [__O1__] ]
-[[`J T::elements_end()`] [__O1__] [__O1__] ]
-[[`J T::elements_rbegin()`] [__O1__] [__O1__] ]
-[[`J T::elements_rend()`] [__O1__] [__O1__] ]
+[[`J elements_begin(T&)`] [__O1__] [__O1__] ]
+[[`J elements_end(T&)`] [__O1__] [__O1__] ]
+[[`J elements_rbegin(T&)`] [__O1__] [__O1__] ]
+[[`J elements_rend(T&)`] [__O1__] [__O1__] ]
]
[table
[[['*Element iteration*]] [Description] ]
-[[`` T::element_iterator T::elements_begin()
-T::element_const_iterator T::elements_begin()const``] [Returns an element iterator to the first element of the container.] ]
-[[`` T::element_iterator T::elements_end()
-T::element_const_iterator T::elements_end()const``] [Returns an element iterator to a position `elements_end()` after the last element of the container.]]
-[[`` T::element_reverse_iterator T::elements_rbegin()
-T::element_const_reverse_iterator T::elements_rbegin()const``] [Returns a reverse element iterator to the last element of the container.] ]
-[[`` T::element_reverse_iterator T::elements_rend()
-T::element_const_reverse_iterator T::elements_rend()const``] [Returns a reverse element iterator to a position `elements_rend()` before the first element of the container.]]
+[[`` T::element_iterator elements_begin(T&)
+T::element_const_iterator elements_begin(const T&)``] [Returns an element iterator to the first element of the container.] ]
+[[`` T::element_iterator elements_end(T&)
+T::element_const_iterator elements_end(const T&)``] [Returns an element iterator to a position `elements_end(c)` after the last element of the container.]]
+[[`` T::element_reverse_iterator elements_rbegin(T&)
+T::element_const_reverse_iterator elements_rbegin(const T&)``] [Returns a reverse element iterator to the last element of the container.] ]
+[[`` T::element_reverse_iterator elements_rend(T&)
+T::element_const_reverse_iterator elements_rend(const T&)``] [Returns a reverse element iterator to a position `elements_rend(c)` before the first element of the container.]]
]
+['*Example*]
+
+``
+interval_set<int> inter_set;
+inter_set.add(interval<int>::right_open(0,3))
+ .add(interval<int>::right_open(7,9));
+
+for(interval_set<int>::element_const_iterator creeper = elements_begin(inter_set);
+ creeper != elements_end(inter_set); ++creeper)
+ cout << *creeper << " ";
+cout << endl;
+//Program output: 0 1 2 7 8
+
+for(interval_set<int>::element_reverse_iterator repeerc = elements_rbegin(inter_set);
+ repeerc != elements_rend(inter_set); ++repeerc)
+ cout << *repeerc << " ";
+cout << endl;
+//Program output: 8 7 2 1 0
+``
['*See also . . .*]
[table
Modified: branches/release/libs/icl/doc/html/boost_icl/function_reference/element_iteration.html
==============================================================================
--- branches/release/libs/icl/doc/html/boost_icl/function_reference/element_iteration.html (original)
+++ branches/release/libs/icl/doc/html/boost_icl/function_reference/element_iteration.html 2011-01-10 20:00:04 EST (Mon, 10 Jan 2011)
@@ -174,7 +174,7 @@
<tr>
<td>
<p>
- <code class="computeroutput"><span class="identifier">J</span> <span class="identifier">T</span><span class="special">::</span><span class="identifier">elements_begin</span><span class="special">()</span></code>
+ <code class="computeroutput"><span class="identifier">J</span> <span class="identifier">elements_begin</span><span class="special">(</span><span class="identifier">T</span><span class="special">&)</span></code>
</p>
</td>
<td>
@@ -191,7 +191,7 @@
<tr>
<td>
<p>
- <code class="computeroutput"><span class="identifier">J</span> <span class="identifier">T</span><span class="special">::</span><span class="identifier">elements_end</span><span class="special">()</span></code>
+ <code class="computeroutput"><span class="identifier">J</span> <span class="identifier">elements_end</span><span class="special">(</span><span class="identifier">T</span><span class="special">&)</span></code>
</p>
</td>
<td>
@@ -208,7 +208,7 @@
<tr>
<td>
<p>
- <code class="computeroutput"><span class="identifier">J</span> <span class="identifier">T</span><span class="special">::</span><span class="identifier">elements_rbegin</span><span class="special">()</span></code>
+ <code class="computeroutput"><span class="identifier">J</span> <span class="identifier">elements_rbegin</span><span class="special">(</span><span class="identifier">T</span><span class="special">&)</span></code>
</p>
</td>
<td>
@@ -225,7 +225,7 @@
<tr>
<td>
<p>
- <code class="computeroutput"><span class="identifier">J</span> <span class="identifier">T</span><span class="special">::</span><span class="identifier">elements_rend</span><span class="special">()</span></code>
+ <code class="computeroutput"><span class="identifier">J</span> <span class="identifier">elements_rend</span><span class="special">(</span><span class="identifier">T</span><span class="special">&)</span></code>
</p>
</td>
<td>
@@ -264,8 +264,8 @@
<p>
</p>
-<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"> <span class="identifier">T</span><span class="special">::</span><span class="identifier">element_iterator</span> <span class="identifier">T</span><span class="special">::</span><span class="identifier">elements_begin</span><span class="special">()</span>
-<span class="identifier">T</span><span class="special">::</span><span class="identifier">element_const_iterator</span> <span class="identifier">T</span><span class="special">::</span><span class="identifier">elements_begin</span><span class="special">()</span><span class="keyword">const</span></pre>
+<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"> <span class="identifier">T</span><span class="special">::</span><span class="identifier">element_iterator</span> <span class="identifier">elements_begin</span><span class="special">(</span><span class="identifier">T</span><span class="special">&)</span>
+<span class="identifier">T</span><span class="special">::</span><span class="identifier">element_const_iterator</span> <span class="identifier">elements_begin</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">T</span><span class="special">&)</span></pre>
<p>
</p>
</td>
@@ -280,14 +280,14 @@
<p>
</p>
-<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"> <span class="identifier">T</span><span class="special">::</span><span class="identifier">element_iterator</span> <span class="identifier">T</span><span class="special">::</span><span class="identifier">elements_end</span><span class="special">()</span>
-<span class="identifier">T</span><span class="special">::</span><span class="identifier">element_const_iterator</span> <span class="identifier">T</span><span class="special">::</span><span class="identifier">elements_end</span><span class="special">()</span><span class="keyword">const</span></pre>
+<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"> <span class="identifier">T</span><span class="special">::</span><span class="identifier">element_iterator</span> <span class="identifier">elements_end</span><span class="special">(</span><span class="identifier">T</span><span class="special">&)</span>
+<span class="identifier">T</span><span class="special">::</span><span class="identifier">element_const_iterator</span> <span class="identifier">elements_end</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">T</span><span class="special">&)</span></pre>
<p>
</p>
</td>
<td>
<p>
- Returns an element iterator to a position <code class="computeroutput"><span class="identifier">elements_end</span><span class="special">()</span></code> after the last element of the container.
+ Returns an element iterator to a position <code class="computeroutput"><span class="identifier">elements_end</span><span class="special">(</span><span class="identifier">c</span><span class="special">)</span></code> after the last element of the container.
</p>
</td>
</tr>
@@ -296,8 +296,8 @@
<p>
</p>
-<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"> <span class="identifier">T</span><span class="special">::</span><span class="identifier">element_reverse_iterator</span> <span class="identifier">T</span><span class="special">::</span><span class="identifier">elements_rbegin</span><span class="special">()</span>
-<span class="identifier">T</span><span class="special">::</span><span class="identifier">element_const_reverse_iterator</span> <span class="identifier">T</span><span class="special">::</span><span class="identifier">elements_rbegin</span><span class="special">()</span><span class="keyword">const</span></pre>
+<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"> <span class="identifier">T</span><span class="special">::</span><span class="identifier">element_reverse_iterator</span> <span class="identifier">elements_rbegin</span><span class="special">(</span><span class="identifier">T</span><span class="special">&)</span>
+<span class="identifier">T</span><span class="special">::</span><span class="identifier">element_const_reverse_iterator</span> <span class="identifier">elements_rbegin</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">T</span><span class="special">&)</span></pre>
<p>
</p>
</td>
@@ -312,14 +312,14 @@
<p>
</p>
-<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"> <span class="identifier">T</span><span class="special">::</span><span class="identifier">element_reverse_iterator</span> <span class="identifier">T</span><span class="special">::</span><span class="identifier">elements_rend</span><span class="special">()</span>
-<span class="identifier">T</span><span class="special">::</span><span class="identifier">element_const_reverse_iterator</span> <span class="identifier">T</span><span class="special">::</span><span class="identifier">elements_rend</span><span class="special">()</span><span class="keyword">const</span></pre>
+<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"> <span class="identifier">T</span><span class="special">::</span><span class="identifier">element_reverse_iterator</span> <span class="identifier">elements_rend</span><span class="special">(</span><span class="identifier">T</span><span class="special">&)</span>
+<span class="identifier">T</span><span class="special">::</span><span class="identifier">element_const_reverse_iterator</span> <span class="identifier">elements_rend</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">T</span><span class="special">&)</span></pre>
<p>
</p>
</td>
<td>
<p>
- Returns a reverse element iterator to a position <code class="computeroutput"><span class="identifier">elements_rend</span><span class="special">()</span></code> before the first element of the
+ Returns a reverse element iterator to a position <code class="computeroutput"><span class="identifier">elements_rend</span><span class="special">(</span><span class="identifier">c</span><span class="special">)</span></code> before the first element of the
container.
</p>
</td>
@@ -327,6 +327,30 @@
</tbody>
</table></div>
<p>
+ <span class="emphasis"><em><span class="bold"><strong>Example</strong></span></em></span>
+ </p>
+<p>
+
+</p>
+<pre class="programlisting"><span class="identifier">interval_set</span><span class="special"><</span><span class="keyword">int</span><span class="special">></span> <span class="identifier">inter_set</span><span class="special">;</span>
+<span class="identifier">inter_set</span><span class="special">.</span><span class="identifier">add</span><span class="special">(</span><span class="identifier">interval</span><span class="special"><</span><span class="keyword">int</span><span class="special">>::</span><span class="identifier">right_open</span><span class="special">(</span><span class="number">0</span><span class="special">,</span><span class="number">3</span><span class="special">))</span>
+ <span class="special">.</span><span class="identifier">add</span><span class="special">(</span><span class="identifier">interval</span><span class="special"><</span><span class="keyword">int</span><span class="special">>::</span><span class="identifier">right_open</span><span class="special">(</span><span class="number">7</span><span class="special">,</span><span class="number">9</span><span class="special">));</span>
+
+<span class="keyword">for</span><span class="special">(</span><span class="identifier">interval_set</span><span class="special"><</span><span class="keyword">int</span><span class="special">>::</span><span class="identifier">element_const_iterator</span> <span class="identifier">creeper</span> <span class="special">=</span> <span class="identifier">elements_begin</span><span class="special">(</span><span class="identifier">inter_set</span><span class="special">);</span>
+ <span class="identifier">creeper</span> <span class="special">!=</span> <span class="identifier">elements_end</span><span class="special">(</span><span class="identifier">inter_set</span><span class="special">);</span> <span class="special">++</span><span class="identifier">creeper</span><span class="special">)</span>
+ <span class="identifier">cout</span> <span class="special"><<</span> <span class="special">*</span><span class="identifier">creeper</span> <span class="special"><<</span> <span class="string">" "</span><span class="special">;</span>
+<span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">endl</span><span class="special">;</span>
+<span class="comment">//Program output: 0 1 2 7 8
+</span>
+<span class="keyword">for</span><span class="special">(</span><span class="identifier">interval_set</span><span class="special"><</span><span class="keyword">int</span><span class="special">>::</span><span class="identifier">element_reverse_iterator</span> <span class="identifier">repeerc</span> <span class="special">=</span> <span class="identifier">elements_rbegin</span><span class="special">(</span><span class="identifier">inter_set</span><span class="special">);</span>
+ <span class="identifier">repeerc</span> <span class="special">!=</span> <span class="identifier">elements_rend</span><span class="special">(</span><span class="identifier">inter_set</span><span class="special">);</span> <span class="special">++</span><span class="identifier">repeerc</span><span class="special">)</span>
+ <span class="identifier">cout</span> <span class="special"><<</span> <span class="special">*</span><span class="identifier">repeerc</span> <span class="special"><<</span> <span class="string">" "</span><span class="special">;</span>
+<span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">endl</span><span class="special">;</span>
+<span class="comment">//Program output: 8 7 2 1 0
+</span></pre>
+<p>
+ </p>
+<p>
<span class="emphasis"><em><span class="bold"><strong>See also . . .</strong></span></em></span>
</p>
<div class="informaltable"><table class="table">
Modified: branches/release/libs/icl/test/test_doc_code_/test_doc_code.cpp
==============================================================================
--- branches/release/libs/icl/test/test_doc_code_/test_doc_code.cpp (original)
+++ branches/release/libs/icl/test/test_doc_code_/test_doc_code.cpp 2011-01-10 20:00:04 EST (Mon, 10 Jan 2011)
@@ -70,3 +70,40 @@
cout << "error, identifiers.contains('boost')\n";
}
+BOOST_AUTO_TEST_CASE(function_reference_element_iteration)
+{
+ // begin of doc code -------------------------------------------------------
+ interval_set<int> inter_set;
+ inter_set.add(interval<int>::right_open(0,3))
+ .add(interval<int>::right_open(7,9));
+
+ for(interval_set<int>::element_const_iterator creeper = elements_begin(inter_set);
+ creeper != elements_end(inter_set); ++creeper)
+ cout << *creeper << " ";
+ cout << endl;
+ //Program output: 0 1 2 7 8
+
+ for(interval_set<int>::element_reverse_iterator repeerc = elements_rbegin(inter_set);
+ repeerc != elements_rend(inter_set); ++repeerc)
+ cout << *repeerc << " ";
+ cout << endl;
+ //Program output: 8 7 2 1 0
+ // end of doc code ---------------------------------------------------------
+
+ // Testcode
+ std::stringstream result;
+ for(interval_set<int>::element_iterator creeper2 = elements_begin(inter_set);
+ creeper2 != elements_end(inter_set); ++creeper2)
+ result << *creeper2 << " ";
+
+ BOOST_CHECK_EQUAL(result.str(), std::string("0 1 2 7 8 "));
+
+ std::stringstream tluser;
+ for(interval_set<int>::element_const_reverse_iterator repeerc2
+ = elements_rbegin(const_cast<const interval_set<int>&>(inter_set));
+ repeerc2 != elements_rend(const_cast<const interval_set<int>&>(inter_set)); ++repeerc2)
+ tluser << *repeerc2 << " ";
+
+ BOOST_CHECK_EQUAL(tluser.str(), std::string("8 7 2 1 0 "));
+}
+
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk