comp.lang.ada
 help / color / mirror / Atom feed
From: jm59@prism.gatech.edu (John M. Mills)
Subject: Re: How I declare a 'mod' type within a record?
Date: 1997/08/05
Date: 1997-08-05T00:00:00+00:00	[thread overview]
Message-ID: <5s85mu$acu@acmey.gatech.edu> (raw)
In-Reply-To: 33E78541.15FB@jhuapl.edu


Mars Gralia <mars.gralia@jhuapl.edu> writes:
[Mr. Gralia's comments elided without prejudice, as I don't have the original
post on hand. Please excuse me.]
>Matthew Kennedy wrote, on (apparently) 27-July:
>> I'm trying to implement a time-series type to aid in defference equation
>> simulations. I would like to use a 'mod' type which would be an elegant
>> way of cycling around the buffer (which is just an array).

You may want to consider a circularly linked list which tails back into its
own head and keep track of the current head.  I suppose that you might want
to link pointers forward and backward to quickly address terms at different
relative displacement.  You just keep stuffing newly acquired data at the
moving "head" as the list happily circles back on itself.  A little work
to construct the list (you can't simply "declare" it), then it runs itself.

I saw a comprensive example commonly called a "managed ring buffer" and
attributed to G.Booch.  Unfortunately I do not have a reference at hand.
Perhaps some other reader can direct you.

Otherwise you can certainly use "flat" arrays of your preferred type of
data record and a package to massage their "head" and "tail" pointers
(which are actually array subscripts), as well as to return indices at
different offsets, positive or negative.  The point is to provide a modular
manipulation package with which you manipulate the indices of arrays of
whatever data type you are using.  We did this by brute force in Ada83,
but it looks like a natural opportunity for OOD in Ada95. 

Sorry -- no code, but the linked-list is a common example, including
section 11.4 of Barnes _Programming in Ada_[83].  You want to return (warn)
appropriately when an excessive offset has been requested.  If you are just
"pushing" data and never "popping" it till it's overwritten, you probably
don't have many other errors to detect.

-- 
John M. Mills, Senior Research Engineer   --   john.m.mills@gtri.gatech.edu
   Georgia Tech Research Institute, Georgia Tech, Atlanta, GA 30332-0834
        Phone contacts: 404.894.0151 (voice), 404.894.6258 (FAX)
           "Lies, Damned Lies, Statistics, and Simulations."




      reply	other threads:[~1997-08-05  0:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-07-30  0:00 How I declare a 'mod' type within a record? Matthew Kennedy
1997-07-30  0:00 ` Matthew Heaney
1997-07-31  0:00 ` Robert Dewar
1997-08-05  0:00 ` Mars Gralia
1997-08-05  0:00   ` John M. Mills [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox