|
A singly linked list, where you can only traverse it in one direction, isn't real complicated. I don't think it would perform as well as data stored in some way that guarantees at least the appearance of contiguity, i.e. allows access by indexing or pointer arithmetic. It would be interesting to test it. If you have to sort the data after loading it, or insert at a specific point, the linked list gets more complicated. I've never used one in RPG, except once to prove to myself I still remembered how to build one. > -----Original Message----- > From: M. Lazarus [mailto:mlazarus@ttec.com] > Sent: Friday, December 08, 2000 11:01 AM > To: RPG400-L@midrange.com > Subject: RE: Based variables > > > At 12/8/00 11:33 AM -0600, you wrote: > >The way you do this is to NOT use a field, ONLY use a > pointer that is first > >Allocated to 1 record, and then Reallocated for an > additional record each > >time you read another record in. This creates a completely > dynamic and > >contiguous memory block that holds the records for the file. > The externally > >described Data Structure to the file is Based on a Pointer, and you > >re-calculate this pointer to the correct position in the > dynamic memory > >block. > > Let me get this straight. If the DS is based, the pointer > is set for the > first record read. I increment the pointer to point to the > byte right > after the DS. How do I know I'm not stepping on some valid data in > memory? Do I use ALLOC / REALLOC to reserve it? If yes, > then that should > work well. > > Does it make sense (performance wise) to only add one record to the > memory allocation? Or should I just add, say, 500 records worth. > > > >Another technique in the RPG Programmer's guide is to create > a Linked List. > >The problem with this is that it requires at least 2 > pointers per record, > >and possibly 3, and creates a lot of pointer management > issues. The above > >technique requires only 1 pointer for the data, and an > additional pointer > >for the Based Data Structure. > > I agree that a linked list is too complicated for this application. > > -mark > > +--- > | This is the RPG/400 Mailing List! > | To submit a new message, send your mail to RPG400-L@midrange.com. > | To subscribe to this list send email to RPG400-L-SUB@midrange.com. > | To unsubscribe from this list send email to > RPG400-L-UNSUB@midrange.com. > | Questions should be directed to the list owner/operator: > david@midrange.com > +--- > +--- | This is the RPG/400 Mailing List! | To submit a new message, send your mail to RPG400-L@midrange.com. | To subscribe to this list send email to RPG400-L-SUB@midrange.com. | To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com. | Questions should be directed to the list owner/operator: david@midrange.com +---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.