I want to store a large result set from database in memory. Every record has variable length and access time must be as fast as arrays. What is the best way to implement this? I was thinking of keeping offsets in a separate table and storing all of the records consecutively? Is it odd? (Programming Language: Delphi)
Share
Not sure I totally follow you, but have a look at TList.
In Delphi 7 at least, it is implemented as an arrary of pointers. You can use the capacity property to pre allocate the list ahead of time if you know how many results are coming back.
The list will automatically grow if it runs out of space. How much it grows by depends on how big the list is.
Take a look at the source for the classes unit to see what it’s doing.
Edit: Also in D2009 genric support was added to TList which makes it a bit nicer to use.