|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r67937 - in sandbox/icl/libs/icl: doc test/test_doc_code_
From: afojgo_at_[hidden]
Date: 2011-01-10 19:39:02
Author: jofaber
Date: 2011-01-10 19:38:53 EST (Mon, 10 Jan 2011)
New Revision: 67937
URL: http://svn.boost.org/trac/boost/changeset/67937
Log:
Fixed error in docs: element_iterators are free functions. Added example and test code.
Text files modified:
sandbox/icl/libs/icl/doc/functions_element_iteration.qbk | 43 ++++++++++++++++++++++++++++-----------
sandbox/icl/libs/icl/test/test_doc_code_/test_doc_code.cpp | 37 ++++++++++++++++++++++++++++++++++
2 files changed, 68 insertions(+), 12 deletions(-)
Modified: sandbox/icl/libs/icl/doc/functions_element_iteration.qbk
==============================================================================
--- sandbox/icl/libs/icl/doc/functions_element_iteration.qbk (original)
+++ sandbox/icl/libs/icl/doc/functions_element_iteration.qbk 2011-01-10 19:38:53 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: sandbox/icl/libs/icl/test/test_doc_code_/test_doc_code.cpp
==============================================================================
--- sandbox/icl/libs/icl/test/test_doc_code_/test_doc_code.cpp (original)
+++ sandbox/icl/libs/icl/test/test_doc_code_/test_doc_code.cpp 2011-01-10 19:38:53 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