Boost logo

Boost Users :

From: Guillaume Melquiond (guillaume.melquiond_at_[hidden])
Date: 2004-01-22 06:22:43


Le mer 21/01/2004 à 23:22, David Brownell a écrit :
> I think I am looking for functionality that is contained with the Interval
> library, but am having a hard time digesting the documentation for this
> particular library.

> I would like an Interval that goes from a min_value to a max_value, where
> each value is the previous value + N.

It isn't possible. For the library, the definition of an interval is a
closed and *convex* set of data. As soon as you put this stride N, the
set is not convex anymore. Moreover, you can't define any arithmetic on
such an "interval" (the library is an interval *arithmetic* library).
What you are looking for is probably a "Range" library (this name has
shown up a few times on the Boost mailing-list).

> For example, the interval {2, 6, 10, 14, 18} has a minimum value of 2, a
> maximum value of 18, and increments by 4. Given this interval, I would like
> a function, Foo, that works as follows:
>
> Interval(2, 18, 4) i;
>
> i.Foo(2) == 2
> i.Foo(6) == 2
> i.Foo(0) == 2
> i.Foo(18) == 18
> i.Foo(20) == 18
> i.Foo(5) == 6
> i.Foo(3) == 6

I must be misunderstanding something, because I don't understand at all
what this function is supposed to do. Is it a random function?

> Is this something that can be done with the Interval library, or am I
> missing the point? :)

Sorry; but you are.

> Thanks in advance for your help!
> David Brownell

Regards,

Guillaume


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