Boost logo

Boost :

From: Beman Dawes (bdawes_at_[hidden])
Date: 2001-12-26 20:05:14


At 03:26 AM 12/26/2001, Nathan wrote:

>I have uploaded to the Boost files section a couple of archives
>containing an implementation of a class template extent_set;
>look in the folder "extent_set":
>
> http://groups.yahoo.com/group/boost/files/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; // empty
> 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; // print "(10,40)"
>
>It is implemented using std::map. The insert and erase members are
>about as elegant as anything I have ever coded. There are lots of
>other extensions possible (e.g. union etc.), but it does everything
>I need now.
>
>This is the initial submission. Please 'ave a look.

Interesting.

Did you consider asserting or throwing on b < e precondition violations?

What is the rationale for the insert precondition !has_any(b, e), and the
erase precondition has_all(b, e)? (I'm just curious and not suggesting
that looser preconditions would be better.)

The portion of the license which reads "Permission is granted for any use
free of charge provided..." can be read two ways:

   "Permission free of change is granted for any use provided ..."

   "Permission is granted for any use which is free of charge provided ..."

The first is fine, the second would appear to prevent the use in commercial
software, so wouldn't meet the Boost requirements.

Cheers,

--Beman


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk