Pointers or copies?

BCS BCS at pathilink.com
Wed Dec 20 14:45:35 PST 2006


Orgoton wrote:
> I haven't finished it yet. Well, each frame, the main engine will cycle through
> all the pointers on the queue with something like
> 
> for (i=0; i<queue.size; i++) queue.next().draw();

Take a look at foreach. If queue is an array, this will work:

foreach(item;queue) item.draw();

If it isn't an array, you can implement an opApply.

> 
> That means I can just [...]
> 
> objct objts[];
> 
> void add (in objct target)
> { objts[objts.lenght-1]=target; }
> 
> and it'l work just fine without creating copies of the objects? (and spare me of
> memory problems along the way :P)

yup.

BTW this is the same thing

objts[$-1]=target;






More information about the Digitalmars-d mailing list