MASON-INTEREST-L Archives

January 2012

MASON-INTEREST-L@LISTSERV.GMU.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Sean Luke <[log in to unmask]>
Reply To:
MASON Multiagent Simulation Toolkit <[log in to unmask]>
Date:
Fri, 6 Jan 2012 10:11:58 -0500
Content-Type:
text/plain
Parts/Attachments:
text/plain (22 lines)
On Jan 3, 2012, at 1:01 PM, Axelrod, Benjamin wrote:

> Is there any reason the sim.util.Interval class doesn’t have a method to test whether or not a value falls within the interval?

Absolutely none.  I'll add it.  Also I'll add contains(double) since contains(Number) only autoboxes in later versions of the language (and it not particularly efficient):

    public boolean contains(Number val) { return contains(val.doubleValue()); }
    public boolean contains(double val) { return (val >= min.doubleValue() && val <= max.doubleValue()); }


> It makes using dom sliders and bounds testing a little nicer.  For example:
>  
>     public static double lambda = 1.0;
>     public double getLambda() { return lambda; }
>     public void setLambda(double val) { if (((Interval)domLambda()).contains(val)) lambda = val; }
>     public Object domLambda() { return new Interval(0.0, 1.0); }

Sure.


Sean

ATOM RSS1 RSS2