From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_20,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,7bf4308ff88deca8 X-Google-Attributes: gid103376,public From: jm59@prism.gatech.edu (John M. Mills) Subject: Re: How I declare a 'mod' type within a record? Date: 1997/08/05 Message-ID: <5s85mu$acu@acmey.gatech.edu>#1/1 X-Deja-AN: 262549092 References: <33DF3FD2.20D2@mail.connect.usq.edu.au> <33E78541.15FB@jhuapl.edu> Organization: Georgia Institute of Technology Newsgroups: comp.lang.ada Date: 1997-08-05T00:00:00+00:00 List-Id: Mars Gralia 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."