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

Home » Public Forums » archive » Re: Need ideas for a data structure
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: Need ideas for a data structure [message #3087 is a reply to message #3073] Thu, 03 November 1994 03:04 Go to previous message
steinhh is currently offline  steinhh
Messages: 260
Registered: June 1994
Senior Member
In article <3992q9$2pp@aplcomm.jhuapl.edu>, CroucAR1@subtech1.spacenet.jhuapl.edu writes:
|>
|> I'm trying to devise a way of dealing with a bunch of data items which will
|> consist of a fixed number of header fields and a widely varying number of data
|> entries. For one such item, an anonymous structure seems appropriate, but I
|> don't see how I can generalize this to an array.
|>
|> If I define an array of structures based on the largest array (which I won't
|> know ahead of time anyway), I'll waste a huge amount of memory.
|>
|> I thought of building an array of pointers to anonymous structures, but the
|> structures seem too anonymous for this to work.
|>
[..]

|> PS: I'm bi - it needs to work with both IDL and PV-Wave

I was just about to propose IDL handles, but then I saw your PS, which
makes it slightly more difficult.

But despair not! The solution is to do your own memory management --
I know it's not pretty, nor very efficient, but it works!

I gather that you have a data structure that could be represented
by the following "conglomerate":

Fixed info
-----------
| | ____ --------_____-------- ___ ...... (N entries)
| | |Entry | |Entry |
| | | | | |
----------- -------- --------

and you'd like to store an array of such data conglomerate.

The fixed info is easily put into an array, with two tags, "start"
and "length", in addition to those representing fixed data.

Assuming that each "Entry" is of the same data type -- this is crucial --
create a global (common block) array of, say, a thousand entries, and
associate with it a global counter Nused (initialized to zero), keeping
track of how much of the array that's in use.

Now, each time you need a new conglomerate data sturcture, create the
Fixed info part. You ought to know by this time how many entries are
needed, so initialize the "start" tag in the fixed info with the current
value of "Nused", and increase Nused with the number of entriest that are
reserved for the new data conglomerate.

If the entries are also variable, you need to go one step further down
into the data structure, and implement the same idea there...


Stein Vidar
[Message index]
 
Read Message
Read Message
Previous Topic: multiplot solution
Next Topic: Re: Help with co-ordinate conversions...

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

Current Time: Sat Nov 29 16:16:16 PST 2025

Total time taken to generate the page: 0.64154 seconds