Develop in Delphi 2010 (or other compatible version of Delphi), a custom data storage class that is used to store pieces of data that basically consists of two strings and a boolean value. The class will be used in a time critical section of a Windows application, so it must be built for speed. Because of this, use a sorted binary tree for the data structure. Memory consumption is not an issue.
Procedure AddData(const Key, SubStr : String; const bVal : Boolean);
Procedure GetData(const Key : String; const bVal : Boolean; var List : TStringList);
Procedure RemoveData(const Key : String);
Procedure CountBvals(const : Key, SubStr : String; var bValTrue : Integer; var bValFalse : Integer); overload;
Procedure CountBvals(const : Key: String; var bValTrue : Integer; var bValFalse : Integer); overload;
AddData() is used to add data to the data structure. Each piece of data that is stored consists of a Key and a SubStr, together these two strings are unique, i.e. no two pieces of data can exist in the data structure with the same Key+SubStr. Neither is case sensitive. The AddData() must verify the added data is not duplicate, i.e. already existing in the data storage.
GetData() is used to list all the stored SubStr values of the given Key with the given bVal value. The result list cannon contain duplicate lines. The result list can be sorted or not. The result SubStr's are not case sensitive.
RemoveData() removes all data from the data structure whose Key is the given. The Key is not case sensitive.
CountBvals() calculates the number of items stored with the given Key and checks how many of these items have a bVal of True and how many has a bVal of False and returns these numbers via the var parameters.
The class will be used typically like this:
For i := 1 to 100000 do
For j := 1 to (1..20) do AddData();
CountBvals(Key, x, y);
As you can see, the data storage usually contains 1..20 pieces of data with the same Key, then CountBvals is called and then the data is removed from the class.
Please only bid if you have experience with speed optimized data structures such as binary trees and can start to work on this right away. The final delivery must consist of the class stored in a separate pas file and a simple demo application that can be used to add data to the class and to verify the class works.