Reputation: 32192
For example if I have 5 input intervals
[0,2]
[1,3]
[2,4]
[5,7]
[6,8]
the result should indicate two clusters. Cluster 1
[0,4] with a count of 3
[5,8] with a count of 2
But I've found that boost::icl::interval map doesn't aggregate clusters, but splits on boundaries.
For example the following test case does not give me the result I hoped for
using namespace boost::icl;
interval_map<double,int> map;
map += std::make_pair(interval<double>::right_open(1.0,2.0), 1);
map += std::make_pair(interval<double>::right_open(2.1,3.0), 1);
map += std::make_pair(interval<double>::right_open(2.9,4.0), 1);
std::cerr << map.iterative_size() << std::endl;
EXPECT_EQ(1, map.find(1.5)->second); // passes
EXPECT_EQ(2, map.find(1.0)->second); // passes
EXPECT_EQ(2, map.find(3.1)->second); // fails
and I understand why as this is by design. However is there a different formulation or library I can use to achieve what I require?
I guess what I'd be looking for is a count of the number of merges that occur with boost::icl::interval_set. When a new interval is added to the container it either inserts a new unique interval or merges with a previous interval. However I don't think the number of times the merge occurs is preserved.
Upvotes: 1
Views: 129