|
Boost Users : |
Subject: [Boost-users] [icl] How to find whether a single day intersects a set of intervals?
From: Steve Lorimer (steve.lorimer_at_[hidden])
Date: 2012-08-20 03:53:43
*Hi folks*
*
*
*I have the following use case: I want to store a series of time intervals
in an icl::interval_set and then determine whether a single point in time
intersects one of these intervals.*
*
*
*Here is my first stab at this:
*
icl::interval_set<Time> _badMonths; // Time is an internal class
which defines all comparison operators
std::vector<int> badMonths; // populated with YYMM integers (eg:
1206 for June 2012)
for (int m : badMonths)
{
Time openInterval = Time(2000 + m / 100, m % 100, 1);
// 1st day of the month
Time closeInterval = Time(2000 + m / 100, m % 100 + 1, 1) -
TimeSpan::Days(1); // last day of the month
icl::interval<Time>::type month(openInterval, closeInterval);
_badMonths.insert(month);
}
// it is now my hope that _badMonths will contain a set of
intervals where each interval is a month
*How do I now check whether a single Time instance intersects one of the
intervals in the set? *
Time timepoint;
if (_badMonths &= timepoint)
std::cout << timepoint << " intersects bad months" <<
std::endl;
TIA
Steve
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net