I gang

Develop a fast ExistsInList(List, String) function

Here is a simple function:

==

Function ExistsInList(List : TStringList; Data: String) : Boolean;

Var

i : Integer;

Begin

For i := 0 to List.Count-1 do

begin

If Pos(List[i], Data) > 0 then

begin

Result := True;

Break;

End;

End;

End;

==

Your job is to design and implement in Delphi a speed optimized version of the function. The optimization can take into account the following information that we know about the input data:

1. The List of search words is sorted and usually small (usually 0..10 items)

2. The List of search words usually contains one or more strings which have identical beginning, e.g.:

Foobar 123

Foobar 443 gfd ds

Windows hhgff

Windows Foo

3. The Data input is usually very similar to the Data input of the previous function call. For example, the function is usually called like this:

ExistsInList(List, "foo-foobar-")

ExistsInList(List, "foo-foobar-foo")

ExistsInList(List, "foo-foobar-foobar 123") //Returns true, if the List contains "Foobar 123".

ExistsInList(List, "foo-foobar-foobar 123-fdsfads")

You can implement this as a class or with global variables, if you want to do some pre-processing or if you want to store some data. The function is called almost a million times in a real world application and these calls sum up to almost 800 seconds of runtime.

The code must compile and work under Delphi 2010. You must not use any assemply or any hacky (non-documented) solutions. Unlike the sample code above, the actual function should be case insensitive.

Færdigheder: Algoritme, Delphi

Se mere: delphi fast list, up string, to string, sum solutions, string the, string search algorithm, string processing algorithm, string i, string algorithm, simple search algorithm, simple algorithm example, pos world, pos algorithm, fast string search algorithm, example algorithm, develop algorithm, delphi develop, search string, beginning algorithm, search algorithm example, algorithm world, algorithm string, algorithm sample code, algorithm input, algorithm function

Om arbejdsgiveren:
( 588 bedømmelser ) Turku, Thailand

Projekt-ID: #4062161

Tildelt til:

benny34

Hi sire, i can do this job for you if you offer me this chance.

$50 USD in 4 dage
(1 bedømmelse)
1.7

2 freelancere byder i gennemsnit $100 for dette job

crazyboy327

Hi,sir. Please check your PMB.

$150 USD in 4 dage
(1 bedømmelse)
1.6