
2011/2/24 John Reid <j.reid@mail.cryst.bbk.ac.uk>:
On 24/02/11 11:42, Joachim Faulhaber wrote:
(2) Generalization of "find" in the Set view and the STL/iterator view.
2011/2/23 John Reid<j.reid@mail.cryst.bbk.ac.uk>:
On 22/02/11 20:03, Joachim Faulhaber wrote:
2011/2/22 John Reid<j.reid@mail.cryst.bbk.ac.uk>
interval_map::find is a pretty late addition to ITL/ICL, because using find in the STL way makes little sense on interval containers most of the time. We can not "find" an large interval in an icl::interval_set of small intervals.
{[0,2),[5,7)}.find([0,9))
Now I'm a bit confused,
sorry I confused myself here :-/
I thought when you said 'We can not "find" an large interval' you meant the following isn't supported:
namespace icl = ::boost::icl; typedef float type_; icl::interval_set< type_ > set; set.add( icl::interval< type_ >::type( 0, 2 ) ); set.add( icl::interval< type_ >::type( 5, 7 ) ); set.find( icl::interval< type_ >::type( 0, 9 ) );
but it does compile just fine.
Yep. (1) The documentation of find http://www.boost.org/doc/libs/1_46_0/libs/icl/doc/html/boost_icl/function_re... is not consistent with the implementation. (2) As with lower_bound, upper_bound and equal_range, 'find' is implemented for a generalized semantics: Like lower_bound, find returns an iterator to the first interval that overlaps with the search interval. BOOST_AUTO_TEST_CASE(generalized_find) { typedef icl::interval_set<int>::const_iterator int_set_iterator; icl::interval_set<int> int_set; icl::interval<int>::type to_be_found(1,5); int_set += icl::interval<int>::type(0,2); int_set += icl::interval<int>::type(4,7); int_set += icl::interval<int>::type(8,9); int_set_iterator found; found = int_set.lower_bound(to_be_found); cout << *found << endl; // [0,2) found = int_set.find(to_be_found); cout << *found << endl; // [0,2) found = int_set.upper_bound(to_be_found); cout << *found << endl; // [8,9) std::pair<int_set_iterator,int_set_iterator> exterior; exterior = int_set.equal_range(to_be_found); cout << "[" << *exterior.first << "," << *exterior.second << ")" << endl; // [[0,2),[8,9)) } Cheers, Joachim -- Interval Container Library [Boost.Icl] http://www.joachim-faulhaber.de