Deleting specific instances of the structure [message #87351] |
Mon, 27 January 2014 14:51  |
midhunjoyp
Messages: 5 Registered: January 2014
|
Junior Member |
|
|
Hi all,
I am having some difficulty working with structure arrays.
I initialized an array of 10 structures with the following fields.
domain = REPLICATE({frame :0, particles : fltarr(5,6000),link : [-1,-1]}, 10)
The calculations were performed for each field of the structure array. After calculations, there are some instances of the structure which are empty and needs to be deleted.
For eg, out of the 10 structure instances, domain[2], domain[6],domain[7] are the empty ones and needs to be deleted and the final result should have only 7 elements in the structure array.
Is there any way to perform delete operation(other than creating a new structure and assigning the selected ones to it) ?
Best,
Midhun
|
|
|
|
Re: Deleting specific instances of the structure [message #87353 is a reply to message #87351] |
Mon, 27 January 2014 15:01   |
Matthew Argall
Messages: 286 Registered: October 2011
|
Senior Member |
|
|
> For eg, out of the 10 structure instances, domain[2], domain[6],domain[7] are the empty ones and needs to be deleted and the final result should have only 7 elements in the structure array.
If you already know the structures you want to keep, you can just pick them out...
IDL> domain = REPLICATE({frame :0, particles : fltarr(5,6000),link : [-1,-1]}, 10)
IDL> iKeep = [0,1,3,4,5,8,9]
IDL> domain = domain[iKeep]
IDL> Help, domain
|
|
|
Re: Deleting specific instances of the structure [message #87360 is a reply to message #87351] |
Tue, 28 January 2014 06:48  |
midhunjoyp
Messages: 5 Registered: January 2014
|
Junior Member |
|
|
On Monday, January 27, 2014 5:51:18 PM UTC-5, midhu...@gmail.com wrote:
> Hi all,
>
>
>
> I am having some difficulty working with structure arrays.
>
>
>
> I initialized an array of 10 structures with the following fields.
>
>
>
> domain = REPLICATE({frame :0, particles : fltarr(5,6000),link : [-1,-1]}, 10)
>
>
>
> The calculations were performed for each field of the structure array. After calculations, there are some instances of the structure which are empty and needs to be deleted.
>
>
>
> For eg, out of the 10 structure instances, domain[2], domain[6],domain[7] are the empty ones and needs to be deleted and the final result should have only 7 elements in the structure array.
>
>
>
> Is there any way to perform delete operation(other than creating a new structure and assigning the selected ones to it) ?
>
>
>
> Best,
>
> Midhun
Hi Phillip & Matthew,
That was a really good suggestion. Thanks a lot for the help.
Best,
Midhun
|
|
|