Supreme Council
Joined: 2006/11/19 18:16 Last Login
: Yesterday 11:05
From London, England
Group:
Webmasters Registered Users
|
While arrays are handy for fixed amounts of data, if you find yourself with variable amounts, may I suggest you move to linked lists.
Resizing arrays is extremely hard on memory (typically fragmenting it more and more (although the situation on OS4 is better than previous versions)) and is generally kludgy and very error prone.
A linked list allows you to dynamically add "nodes" to the list, remove them, sort them etc. Check out the "Exec Lists" section of the "RKRM Devices" if you have a copy, or at least check the AddTail(), AddHead(), Remove(), Insert() ,Enqueue(), GetHead(), GetSucc() and GetPrev() function autodocs.
If you dont need the overhead of a full list, a MinList might be more suitable. Again the function autodocs should point you in the right direction, and certainly the RKRMs.
The RKRMs are available in AmigaGuide format on the developer CD2.1 available from a good Amiga shop near you :)
There should be plenty of examples out there too, as code intended for 2.04 is still valid when it comes to linked lists.
Simon
|