Using Boost ICL for range matching

Hello,
I want to know if I can use the boost::icl::interval_set to store a set of
integer based intervals like:
[100, 200], [50, 600] etc
and then find out whether a number like 150 matches any of these intervals?
I would greatly appreciate if someone can point me to an example for this
kind of operation.
Thanks,
Raj
--
Twitter: @Blismedia http://twitter.com/#%21/blismobile
BlisMedia
32 Percy Street,
London W1T 2DE
www.blismedia.com http://www.blismobile.com/
http://www.blismobile.com/
[image: Follow on Twitter] http://twitter.com/#%21/blismobile[image: Blis
Website] http://www.blismobile.com/
This communication is from Blis Media Ltd, a company registered in England
and Wales with registered number 06455773. Its registered office is 32
Percy Street, London W1T 2DE, United Kingdom.
This communication contains information that is confidential and may also
be privileged. It is for the exclusive use of the intended recipient(s). If
you are not the intended recipient(s), please (1) notify info@blismedia.com

2012/6/18 Rajalakshmi Iyer
Hello,
I want to know if I can use the boost::icl::interval_set to store a set of integer based intervals like: [100, 200], [50, 600] etc
and then find out whether a number like 150 matches any of these intervals?
An icl::interval_set does not store the individual intervals that are
inserted into it, if they overlap. Basically the interval set is just a set
that stores contiguous chunks of elements in a compact way as intervals. So
...
#include

Thanks Joachim,
A follow-up question. What would be performance of this lookup on an
interval_set? I am assuming it definitely performs much better that
iterating over each interval in the set to find the range match.
Regards,
Raj
On Thu, Jun 21, 2012 at 8:17 AM, Joachim Faulhaber
2012/6/18 Rajalakshmi Iyer
Hello,
I want to know if I can use the boost::icl::interval_set to store a set of integer based intervals like: [100, 200], [50, 600] etc
and then find out whether a number like 150 matches any of these intervals?
An icl::interval_set does not store the individual intervals that are inserted into it, if they overlap. Basically the interval set is just a set that stores contiguous chunks of elements in a compact way as intervals. So ...
#include
#include using namespace std; using namespace boost::icl; interval_set<int> aSet; //aSet={} aSet += interval<int>::closed(100,200); //aSet={[100,200]} aSet += interval<int>::closed( 50,600); //aSet={[ 50,600]} cout << "aSet " << (contains(aSet, 150) ? "contains 150\n" : "does not contain 150\n");
The example you ask for will look like this.
HTH, Joachim
-- Interval Container Library [Boost.Icl] http://www.joachim-faulhaber.de
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
--
*Twitter: @Blismedia http://twitter.com/#%21/blismobile
BlisMedia
32 Percy Street,
London W1T 2DE
www.blismedia.com http://www.blismobile.com/**
*** http://www.blismobile.com/*
****[image: Follow on Twitter]* http://twitter.com/#%21/blismobile*[image:
Blis Website]* http://www.blismobile.com/
*This communication is from Blis Media Ltd, a company registered in England
and Wales with registered number 06455773. Its registered office is 32
Percy Street, London W1T 2DE, United Kingdom.*
* *
*This communication contains information that is confidential and may also
be privileged. It is for the exclusive use of the intended recipient(s). If
you are not the intended recipient(s), please (1) notify info@blismedia.com

2012/6/21 Rajalakshmi Iyer
Thanks Joachim,
A follow-up question. What would be performance of this lookup on an interval_set? I am assuming it definitely performs much better that iterating over each interval in the set to find the range match.
It's O(lg(n)) where n is the number of intervals in the interval_set. Please look up such information in the libraries documentation. Regrards, Joachim -- Interval Container Library [Boost.Icl] http://www.joachim-faulhaber.de
participants (2)
-
Joachim Faulhaber
-
Rajalakshmi Iyer