Arrays Vs Linked Lists
I have a question, more to gauge the opinions of board users.
I have a simple 'relational' database of information stored in multiple structs, the information from these structs is stored in separate files. The size of these files will always stay fairly small, not more than 200-250 entries in the largest file. I think this is small enough to hold in memory during the operation of the program, and only write back to file when closing the app. Any new information would be added at the end of the memory rather than part way through (that is, any new structure dumped at the end of the array/linked list).
In these circumstances, which would be the suggested route for storage, an array of structs, or a linked list of structs? I assume both have advantages and disadvantages, arrays would probably be faster and could be extended with realloc (or whatever the C++ version is), but it would be difficult to remove items in the array as the memory used is contiguous. Linked lists would probably be the slower but offer more flexibility to add/remove items. I am not sure which way to go as both are possible (although the linked lists would be easier I suspect), so if anyone has any strong feelings one way or the other I would be interested in hearing what you have to say.
Try them both, and learn some first hand experiences about which is best for a given circumstance so that you'll be better able to answer the "which do I use questions" in future.
In the meantime, read the first couple of responses from Zach here
>not more than 200-250 entries in the largest file
Then it really doesn't matter what data structure you use unless the entries are HUGE, where the constant shifting of elements in an array will be noticeably expensive. The differences in data structures typically only show up as the number of items grows beyond, for example, 5000. So use whichever is simplest.
In my case, the one mentioned in the linked article, I opted for using vectors and have been happy with the results.