10

What is the best way to implement variable-length arrays?

 2 years ago
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.
neoserver,ios ssh client

What is the best way to implement variable-length arrays?

advertisements

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?

I've got just one simple silly question: What's the best way to implement Facebook on my application? Add an easy UIWebView connecting to the Url of the Faceboook page I want to show; Implement the API I found in several answer all of you already gav

What is the best way to implement this class in C #

I have a class(let's call it foo) which contains 20 members. The class has a method public foo Rotate(double angle). This method rotates calling object with certain angle and creates a new foo object. 10 members of the new object is always the same a

Multi-file program C, what is the best way to implement optional recording?

I have a multi file C program. I'd like the user to be able to specify different debugging levels at run time. What is the best way to implement this? I was thinking of having a debug(level, "message") type function exported and used everywhere.

What is the best way to implement user account activation?

What is best practice for the android/ios app with following scenario: Client company sends user's emails/numbers to us. We create accounts for users with sent data. Each user installs app, logs in with email and -> at this point he/she should prove

What is the best way to implement a substring search in SQL?

We have a simple SQL problem here. In a varchar column, we wanted to search for a string anywhere in the field. What is the best way to implement this for performance? Obviously an index is not going to help here, any other tricks? We are using MySQL

What is the best way to implement a data source that serves multiple tables in iOS

I have three UITableView's and they all need access to essentially the same data. The only difference is how each table view formats the data. What is the best way to implement this? I was thinking that if each table view had a tag of some sort, I co

What is the best way to implement a background task that can be canceled in MonoTouch?

The C# async await feature is not yet available in MonoTouch 6.0. Until then what is the best way to implement an async task in MonoTouch. The MonoTouch docs recommend Threading from the System.Threading namespace to create responsive UI. But once th

What is the best way to implement full-text search for Google App Engine Java?

What is the best way to implement fulltext search for Google App Engine Java? Solr doesn't work out of the box Lucene-based searchengine has limitation with the index size the latest search is not available for Java yet (experimental or not) So what

What is the best way to implement many-to-many relationships using ORMLite?

I'm currently playing with ORMlite to make a model with tables and relationships. One relationship is a many-to-many relationship. What's the best way to implement that? To be more concrete: Let's say I've got these two tables Product id brand Purcha

What is the best way to implement multiple flex components?

I'm developing a Flex/AIR application that's growing big, and some of the components need to be seen from different points of view (i.e Admin, Staff, User, Guest). I've seen myself placing code in those components to handle what the user can and can'

What is the best way to implement a python tree structure

What is the best way to implement a tree structure (generic - not binary) in python? My intuition would have the following skeleton: class TNode(self, data): #enter things for each individual node class TStructure(self): #enter code for implementing

What is the best way to pass variables to my unit test instances?

I've got test classes that inherit from unittest.TestCase. I load the classes multiple times like so: tests = [TestClass1, TestClass2] for test in tests: for var in array: # somehow indicate that this test should have the value of 'var' suite.addTest

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 (or, is there a way) to implement a dependency property while avoiding the code analysis warning for CA2104 (Do not declare readonly mutable reference types)? The MSDN documentation suggests this way of declaring your dependency

What is the best way to implement a method that performs rather cumbersome operations like updating a database, retrieving a database?

I have a piece of code about few hundread lines, this code is inside a while loop which gets executed each time for about 1000 records. I want to move this code out of the while loop and place it in a seperate method , what is the best way improve th

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK