comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Empty arrays?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Empty arrays? [message #63437] Mon, 10 November 2008 14:56 Go to previous message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
On Nov 10, 3:35 pm, Spon <christoph.b...@gmail.com> wrote:
> For these sorts of cases, I tend to use empty pointers. Here's an
> example using pointers to provide the functionality I think you're
> looking for:
>
> var = ptr_new(/allocate_heap)
> help, *var
> IDL> <PtrHeapVar1>   UNDEFINED = <Undefined>
>
> This article by JD Smith on David Fanning's website should help get
> you started on pointers:http://www.dfanning.com/misc_tips/pointers.html

Yes, empty pointers work well for these type of things, but there are
still two issues with them in this situation:

1. you still have to check to see if *var is undefined to determine
if you are appending to or creating an array.

2. repeatedly appending to an array is inefficient

A better solution is to create a reasonable sized array to begin with.
Then fill in values and keep track of how many are filled in. If the
array fills up, create a new bigger one and copy the values over. Of
course, this is even more of a hassle with bookkeeping, so I made an
object that does this for me, see:

http://michaelgalloy.com/2006/04/24/collection-package-mgarr aylist.html

Of course, it would be nicer if IDL just allowed empty arrays, but
there would be a lot of backward compatibilities if that were the
case.

Mike
--
www.michaelgalloy.com
Tech-X Corporation
Associate Research Scientist
[Message index]
 
Read Message
Read Message
Previous Topic: error handling
Next Topic: Re: VM Application Error

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 18:25:32 PDT 2025

Total time taken to generate the page: 0.00179 seconds