MASON-INTEREST-L Archives

July 2013

MASON-INTEREST-L@LISTSERV.GMU.EDU

Options: Use Monospaced Font
Show HTML 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:
Joey Harrison <[log in to unmask]>
Reply To:
MASON Multiagent Simulation Toolkit <[log in to unmask]>
Date:
Mon, 8 Jul 2013 22:39:41 -0400
Content-Type:
multipart/alternative
Parts/Attachments:
text/plain (2020 bytes) , text/html (7 kB)
I just whipped these up:


    /**
     * Replace instances of one value to another.
     * @param from any element that matches this value will be replaced
     * @param to with this value
     */
    public void replace(int from, int to)
     {
     for (int x = 0; x < width; x++)
     for (int y = 0; y < height; y++)
     if (field[x][y] == from)
     field[x][y] = to;
     }

---

    /**
     * Replace instances of one value to another.
     * @param from any element that matches this value will be replaced
     * @param to with this value
     */
    public void replace(double from, double to)
     {
     for (int x = 0; x < width; x++)
     for (int y = 0; y < height; y++)
     if (field[x][y] == from)
     field[x][y] = to;
     }

With Sean's permission, I'll check them in.

Joey

On Mon, Jul 8, 2013 at 10:38 PM, Joey Harrison <[log in to unmask]>wrote:

> I just whipped these up:
>
>
>     /**
>      * Replace instances of one value to another.
>      * @param from any element that matches this value will be replaced
>      * @param to with this value
>      */
>     public void replace(int from, int to)
>     {
>     for (int x = 0; x < width; x++)
>     for (int y = 0; y < height; y++)
>     if (field[x][y] == from)
>     field[x][y] = to;
>     }
>
> ---
>
>     /**
>      * Replace instances of one value to another.
>      * @param from any element that matches this value will be replaced
>      * @param to with this value
>      */
>     public void replace(double from, double to)
>     {
>     for (int x = 0; x < width; x++)
>     for (int y = 0; y < height; y++)
>     if (field[x][y] == from)
>     field[x][y] = to;
>     }
>
> With Sean's permission, I'll check them in.
>
> Joey
>
> On Mon, Jul 8, 2013 at 8:46 PM, Mark Coletti <[log in to unmask]> wrote:
>
>> I'd like, as a convenience, for these member functions:
>>
>> IntGrid2D.replace(int from, int to); // change all values of 'from' to
>> 'to'
>> DoubleGrid2D.replace(double from, double to);
>>
>> (I'd do it myself, but this is outside GeoMason's bailiwick.)
>>
>> --
>> [log in to unmask]
>>
>>
>


ATOM RSS1 RSS2