Re: Insert row in structure [message #14588] |
Fri, 12 March 1999 00:00 |
David Foster
Messages: 341 Registered: January 1996
|
Senior Member |
|
|
Joe Means wrote:
>
> Howdy, I would like an effecient way to insert a row or observation in a
> structure. The structure is simple like:
> data = {data1,num:0L,x:0.0,y:0.0,z0.0}
> dataout = Replicate(data,100000L)
>
> I will have to insert, and at other times append, rows into dataout.
>
> thanks for any ideas,
> Joe
> --
Joe -
I surely might be missing something, but this problem looks like
it could be solved very effectively by using a linked list of
structures. This would make it very easy to insert or append
nodes, and you could "sort" your nodes by keeping an array of
pointers to the nodes, and just sort the pointers (instead of
the structures, which is inefficient).
Dave
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
David S. Foster Univ. of California, San Diego
Programmer/Analyst Brain Image Analysis Laboratory
foster@bial1.ucsd.edu Department of Psychiatry
(619) 622-5892 8950 Via La Jolla Drive, Suite 2240
La Jolla, CA 92037
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
|
|
|
Re: Insert row in structure [message #14595 is a reply to message #14588] |
Thu, 11 March 1999 00:00  |
Joe[2]
Messages: 11 Registered: May 1998
|
Junior Member |
|
|
Yeah, I agree - very confusing. I guess that I would make dataout
big enough to hold the longest possible set of data's and just
append. Then after it is all done resort dataout to the desired order.
Otherwise, you are going to have to move large blocks of data
around every time you do an 'insert'. you are obviously sorting
these data by some criteria. Either add that info to the data's or
keep it as a separate array.
Joe Zawodny
> Joe Means (means@fsl.orst.edu) writes:
>
>> Howdy, I would like an effecient way to insert a row or observation in a
>> structure. The structure is simple like:
>> data = {data1,num:0L,x:0.0,y:0.0,z0.0}
>> dataout = Replicate(data,100000L)
>>
>> I will have to insert, and at other times append, rows into dataout.
>
> I don't think I understand what you are looking for.
> Is a "row" or "observation" another DATA1 structure?
> Or do you want to add another field to each DATA1 structure?
>
> Or does "insert a row" mean to add another DATA1
> structure into the middle of the dataout array of
> structures?
>
> I'm confused. :-(
>
> Cheers,
>
> David
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting
> Phone: 970-221-0438 E-Mail: davidf@dfanning.com
> Coyote's Guide to IDL Programming: http://www.dfanning.com/
> Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|
Re: Insert row in structure [message #14596 is a reply to message #14595] |
Thu, 11 March 1999 00:00  |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
Whoops, I wrote:
> Well, then. How about something like this:
>
> data = {data1,num:0L,x:0.0,y:0.0,z0.0}
> dataout = Replicate(data, 100000L)
>
> Insert new DATA1 structure into position 98 in the array:
>
> newdata = {DATA1}
> dataout = dataout[0:96, newdata, 97:*]
And people who look out for me gently point out that
I meant this:
dataout = [dataout[0:96], newdata, dataout[97:*]]
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|
Re: Insert row in structure [message #14607 is a reply to message #14595] |
Thu, 11 March 1999 00:00  |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
Joe Means (means@fsl.orst.edu) writes:
> David, My answers to your questions are inserted in CAPS.
> Joe
>
> David Fanning wrote:
>
>> Joe Means (means@fsl.orst.edu) writes:
>>
>>> Howdy, I would like an effecient way to insert a row or observation in a
>>> structure. The structure is simple like:
>>> data = {data1,num:0L,x:0.0,y:0.0,z0.0}
>>> dataout = Replicate(data,100000L)
>>>
>>> I will have to insert, and at other times append, rows into dataout.
>>
>> I don't think I understand what you are looking for.
>> Is a "row" or "observation" another DATA1 structure? --YES--
>> Or do you want to add another field to each DATA1 structure? --NO--
>>
>> Or does "insert a row" mean to add another DATA1
>> structure into the middle of the dataout array of
>> structures? --YES--
Well, then. How about something like this:
data = {data1,num:0L,x:0.0,y:0.0,z0.0}
dataout = Replicate(data, 100000L)
Insert new DATA1 structure into position 98 in the array:
newdata = {DATA1}
dataout = dataout[0:96, newdata, 97:*]
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|
Re: Insert row in structure [message #14609 is a reply to message #14595] |
Thu, 11 March 1999 00:00  |
Joe Means
Messages: 44 Registered: November 1996
|
Member |
|
|
David, My answers to your questions are inserted in CAPS.
Joe
David Fanning wrote:
> Joe Means (means@fsl.orst.edu) writes:
>
>> Howdy, I would like an effecient way to insert a row or observation in a
>> structure. The structure is simple like:
>> data = {data1,num:0L,x:0.0,y:0.0,z0.0}
>> dataout = Replicate(data,100000L)
>>
>> I will have to insert, and at other times append, rows into dataout.
>
> I don't think I understand what you are looking for.
> Is a "row" or "observation" another DATA1 structure? --YES--
> Or do you want to add another field to each DATA1 structure? --NO--
>
> Or does "insert a row" mean to add another DATA1
> structure into the middle of the dataout array of
> structures? --YES--
>
> I'm confused. :-(
>
> Cheers,
>
> David
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting
> Phone: 970-221-0438 E-Mail: davidf@dfanning.com
> Coyote's Guide to IDL Programming: http://www.dfanning.com/
> Toll-Free IDL Book Orders: 1-888-461-0155
--
From:
Joseph E. Means, Assistant Professor
Forest Science Department Means@fsl.orst.edu
Oregon State University 541-750-7351 Fax 541-750-7329
Corvallis, OR 97331 USA www.fsl.orst.edu/~means/means.htm
|
|
|
Re: Insert row in structure [message #14623 is a reply to message #14595] |
Wed, 10 March 1999 00:00  |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
Joe Means (means@fsl.orst.edu) writes:
> Howdy, I would like an effecient way to insert a row or observation in a
> structure. The structure is simple like:
> data = {data1,num:0L,x:0.0,y:0.0,z0.0}
> dataout = Replicate(data,100000L)
>
> I will have to insert, and at other times append, rows into dataout.
I don't think I understand what you are looking for.
Is a "row" or "observation" another DATA1 structure?
Or do you want to add another field to each DATA1 structure?
Or does "insert a row" mean to add another DATA1
structure into the middle of the dataout array of
structures?
I'm confused. :-(
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|