MASON-INTEREST-L Archives

October 2015

MASON-INTEREST-L@LISTSERV.GMU.EDU

Options: Use Monospaced Font
Show HTML Part by Default
Condense Mail Headers

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

Print Reply
Sender:
MASON Multiagent Simulation Toolkit <[log in to unmask]>
Date:
Sat, 24 Oct 2015 21:56:10 -0400
MIME-version:
1.0 (Mac OS X Mail 7.3 \(1878.6\))
Reply-To:
MASON Multiagent Simulation Toolkit <[log in to unmask]>
Content-type:
text/plain; charset=us-ascii
Subject:
From:
Sean Luke <[log in to unmask]>
In-Reply-To:
Message-ID:
Content-Transfer-Encoding:
8bit
Parts/Attachments:
text/plain (22 lines)
Iterating over all the objects in an ObjectGrid2D means iterating over every single
cell in the array.  If you don't have a lot of objects relative to the cells, this can
be very slow, and it would make more sense to use a SparseGrid2D instead.

You could use a double for-loop to go through all the objects.  But elements() isn't too slow, and it's O(1).

Sean

On Oct 24, 2015, at 10:37 AM, Axel Kowald <[log in to unmask]> wrote:

> Hello Together,
> 
> I just wonder what the best way is to iterate over all the agent on my
> ObjectGrid2D ?
> Currently I'm extracting a Bag with all agents by using the elements()
> method. It works, but I'm not sure how fast/slow it is. Would it be
> worth to maintain my own Bag and do the bookkeeping by
> inserting/removing agents when needed?
> 
> thanx,
>  Axel

ATOM RSS1 RSS2