What is the best way to implement variable-length arrays?
source link: https://www.codesd.com/item/what-is-the-best-way-to-implement-variable-length-arrays.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
What is the best way to implement variable-length arrays?
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)
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.
Related Articles
What is the best way to implement Facebook on my app?
What is the best way to implement this class in C #
Multi-file program C, what is the best way to implement optional recording?
What is the best way to implement user account activation?
What is the best way to implement a substring search in SQL?
What is the best way to implement a data source that serves multiple tables in iOS
What is the best way to implement a background task that can be canceled in MonoTouch?
What is the best way to implement full-text search for Google App Engine Java?
What is the best way to implement many-to-many relationships using ORMLite?
What is the best way to implement multiple flex components?
What is the best way to implement a python tree structure
What is the best way to pass variables to my unit test instances?
What is the best way to implement a dependencyProperty and also avoid 'CA2104: Do not declare mutable reference types read-only'?
What is the best way to implement a method that performs rather cumbersome operations like updating a database, retrieving a database?
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK