I gang

Implement two speed optimized string search functions

Your job is to implement the following two functions that are used to search an array of strings from a given string without case sensitivity.

FastPosExArr(const SubStrs : Array of String; const Str : String);

* Finds the first occurrences of the given SubStrs from Str. The way you return the results (array of integer) is up to you, either use a var parameter or return as a function result. The function is case insensitive.

The implementation is basically an optimized version of this:

for i := low(SubStrs) to high(SubStrs) do result[i] := Pos(LowerCase(SubStrs[i]), LowerCase(Str));

But instead the above implementation, I want you to iterate through the given input Str only one time and search for the given array of SubStrs during the single iteration and quit the iteration as soon as the first occurrence of *each* SubStrs is found.

Since I am using only two or three SubStrs for over 95% of cases, I want you to also implement the following for maximal optimization:

FastPosExArr(const SubStr1 : String; const SubStr2 : String; const Str : String); overload;

FastPosExArr(const SubStr1 : String; const SubStr2 : String; const SubStr3 : String const Str : String); overload;

FastArrValExistsInStr(const SubStrs : Array of String; const Str : String; );

* Finds the first occurrences of the given SubStrs from Str. The function exists as soon as it finds the first hit, therefore the result of this function is the index of which SubStrs it found from Str and the index of which position it was found. The function is case insensitive.

The implementation is basically an optimized version of this:

for i := low(SubStrs) to high(SubStrs) do

begin

Temp := Pos(LowerCase(SubStrs[i]), LowerCase(Str));

If Temp > 0 then

begin

ResultArrIdx := i;

ResultPos := Temp;

Break

End;

End;

But instead the above implementation, I want you to iterate through the given input Str only one time and search for the given array of SubStrs during the single iteration and quit the iteration as soon as the first occurrence of *any* SubStrs is found.

Since I am using only two or three SubStrs for over 95% of cases, I want you to also implement the following for maximal optimization:

FastArrValExistsInStr(const SubStr1 : String; const SubStr2 : String; const Str : String); overload;

FastArrValExistsInStr(const SubStr1 : String; const SubStr2 : String; const SubStr3 : String const Str : String); overload;

Your implementation must work with Delphi 2010 and the implementation must be pure Delphi, no assembler. Please only make a bid if you can do this right now, and you have experience with this kind of work. Do not bid if you are not sure whether you can make these functions faster than the sample implementation codes above.

Færdigheder: Algoritme, Delphi

Se mere: up string, to string, string the, string search algorithm c, string search algorithm, string i, string algorithm, search string c, search string, search c string, quit job, quit a job, pos algorithm, make algorithm, job search optimization, index search algorithm, c string search, c search string, a search algorithm, array search algorithm, algorithm string, algorithm input, algorithm functions, algorithm function, algorithm for search

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

Projekt-ID: #4099734

Tildelt til:

gyk

Hello, Maybe I can make it a little bit faster.

$30 USD på 1 dag
(9 bedømmelser)
5.2