[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: do I really need to use loops on objects?

Struan Gray wrote:
>         Reading this thread has piqued my curiosity as to what people are
> using arrays of objects for.  I like to use IDL_containers instead, as
> they simplify adding and removing objects while maintaining a logical
> order that can be related to numerical array elements if you choose.
> As JD points out you can easily subclass the container, modify the add
> method so it gets picky as to what sort of objects it accepts, and
> provide a DoMethod method to call the relevant method for all the
> contained objects.  Are there applications where doing it this way is
> a bad idea (or impossible)?
> Struan

If you implement your own IDL_Container-like class, it often contains an
internal object array, though the one I use most contains merely a pointer
array, so the array elements need not be simply objects.  Basically, if you have
a collection of objects which need not be intimately related (e.g. if you're
just going to kill them all), an objarr is fine. It's lighter weight than a
container, though less fully featured.


 J.D. Smith                             |*|      WORK: (607) 255-5842    
 Cornell University Dept. of Astronomy  |*|            (607) 255-6263
 304 Space Sciences Bldg.               |*|       FAX: (607) 255-5875 
 Ithaca, NY 14853                       |*|