Re: pointer of pointer [message #48032] |
Thu, 23 March 2006 00:15  |
Antonio Santiago
Messages: 201 Registered: February 2004
|
Senior Member |
|
|
claire.maraldi@gmail.com wrote:
> Hello,
>
> I have to make an array which size of the lines depends of the line.
> I am sure I am not clear so here is an exemple of what I mean :
>
> a is an array of n lines
> each line contain a different number of elements
>
> I have tried to implement something like this
>
> a=PTRARR(n)
> FOR i=0,n-1 DO BEGIN
> a(i)=Ptr_New
> ENDFOR
>
> First I am not sure it is the best way to compute this,
> second if yes I don't how to implemente the value of the "a(i,j)"
> element.
>
As you point, you can do:
n = 10
a = PTRARR(n)
;;Create an array of pointers that points to different byte array
;;sizes.
FOR i=0, n-1 DO BEGIN
a[i] = PTR_NEW( BINDGEN(n*i+10) )
ENDFOR
Ok, now to get a(i,j) take a look at this:
IDL> help, a
A POINTER = Array[10]
IDL> help, a[4]
<Expression> POINTER = <PtrHeapVar25>
IDL> help, *a[4]
<PtrHeapVar25> BYTE = Array[50]
IDL> help, (*a[4])[10]
<Expression> BYTE = 10
The content of fourth position (*a[4]) of the pointer array is an array
of 50 positions. In a general way:
value = (*a[i])[j]
> If somebody can help me...
> Best regards,
>
> Claire
>
I dont' know if this way is as fast as using a "normal" array, that is,
I suposse pointers penalizes on acces time.
--
-----------------------------------------------------
Antonio Santiago P�rez
( email: santiago<<at>>grahi.upc.edu )
( www: http://www.grahi.upc.edu/santiago )
( www: http://asantiago.blogsite.org )
-----------------------------------------------------
GRAHI - Grup de Recerca Aplicada en Hidrometeorologia
Universitat Polit�cnica de Catalunya
-----------------------------------------------------
|
|
|