I have to do the following:
- Replace some numeric integers with string values in a string
- The position of the integers the string may vary
- It all has to be as fast as possible
What we have are some paradox tables with the following format: (TPlayerID : integer)
TableA
PlayerID : TPlayerID
FirstName : string;
SecondName : string;
TableB
BatsmanID : TPlayerID
BowlerID : TPlayerID
Field1
Field2
Field3
OtherBatsmanID : TPlayerID
Field4
etc.
Assume we have the following TPlayerID - TPlayerCode mappings. TPlayerCode : string[5]
1 - ABCDE
2 - FGHIJ
3 - MNOPQ
etc.
If we get strings as follows - say read from a text file:
PlayerID, FirstName, SecondName
3,John,Doe
BatsmanID, BowlerID, Field1, Field2, Field3, OtherBatsmanID, Field4
1,3,a,b,c,2,e
PlayerID, FirstName, SecondName
1,Paul,Smith
BatsmanID, BowlerID, Field1, Field2, Field3, OtherBatsmanID, Field4
2,1,a,b,c,3,e
Question 1:
- What is the most efficient way to store the TPlayerID, TPlayerCode as a memory structure mappings so that:
- Minimal memory footprint
- Fastest searching
The above mappings list does not generally change a lot. So "slow" creation of the mapping list is not a big concern. Typically the mapping list is created once and accessed many. It is nominally read only.
Question 2:
- What is the most efficient way to replace a specific string with another? So given:
BatsmanID, BowlerID, Field1, Field2, Field3, OtherBatsmanID, Field4
1,3,a,b,c,2,e
End up with
BatsmanID, BowlerID, Field1, Field2, Field3, OtherBatsmanID, Field4
ABCDE,MNOPQ,a,b,c,FGHIJ,e
Comments, suggestions welcome. TIA
----------------------------------------------------------------------
Donovan J. Edye [www.edye.wattle.id.au]
Namadgi Systems [www.namsys.com.au]
Voice: +61 2 6285-3460
Fax: +61 2 6285-3459
TVisualBasic = Class(None);
Heard just before the 'Big Bang': "...Uh Oh...."
----------------------------------------------------------------------
GXExplorer [http://www.gxexplorer.org] Freeware Windows Explorer
replacement. Also includes freeware delphi windows explorer components.
----------------------------------------------------------------------