I have uploaded to the Boost files section couple of archives containing an implementation of a class template extent_set; look in the folder "extent_set". The zip and tgz archives there are identical. Included in each is a header file and a test suite. boost::extent_set<> implements a set of half-open ranges on a scalar type, with automatic splitting and merging, appropriate for managing ranges of disk blocks or video frames. In use it looks like: boost::extent_set<int> set; set.insert(10, 20); // now contains [10,20) set.insert(30, 50); // now contains [10,20) [30,50) set.erase(40, 45); // now contains [10,20) [30,40) [45,50) set.insert(20, 30); // now contains [10,40) [45,50) std::cout << "(" << set.begin()->first << "," << set.begin()->second << ")" << std::endl; // writes "(10,40)" It is implemented using std::map. This is the initial submission. Please 'ave a look. (I am only subscribed to the -users list, so far.) Nathan Myers ncm at cantrip dot org
Nathan Myers wrote:
boost::extent_set<> implements a set of half-open ranges on a scalar type, with automatic splitting and merging, appropriate for managing ranges of disk blocks or video frames. In use it looks like:
Cool! Why "extent_set" though? What about range_set or interval_set? Any way this could be adapted to allow non-scalar ranges? What are the requirements on the range element type? I would think anything less-than-comparable should be useable but I didn't implement the class. :) Is there a way to control when ranges are combined (maybe sometimes I want [10, 20) and [20, 30) to stay separate)? A policy for this would be nice. -Dave -- "Some little people have music in them, but Fats, he was all music, and you know how big he was." -- James P. Johnson
participants (2)
-
David A. Greene
-
Nathan Myers