I need some suggestions for solving this problem. I have this data structure:
type
QmyArray = array of integer;
PmyArray = record
element: Qmyarray;
value: integer;
end;
TMyArray = array of Pmyarray;
var
myarray: tmyArray;
myvalue: qmyarray;
I set all values of myarray correctly, and all values of myarray.element are sorted correctly and this is fine. The problem I have is when I want search myvalue in myarray and get value. For searching, I use binarysearch and write:
tarray.BinarySearch(myarray, myvalue, index);
and of course it's not working. Because I understood that need customized the comparer so I write:
function CompareB(const Left, Right: integer): Integer;
begin
if Left < Right then
Result := -1
else if Left > Right then
Result := 1
else
Result := 0;
end;
function CompareA(const Left, Right: pmyarray): Integer;
var
iIndex: Integer;
begin
Result := CompareB(Left.element[0], Right.element[0]);
for iIndex := 1 to High(Right.element) do
if Result = 0 then
Result := CompareB(Left.element[iIndex], Right.element[iIndex]);
end;
and try with:
tarray.BinarySearch(myarray, myvalue, index, TComparer<Pmyarray>.Construct(CompareA));
but in this case I receive this error:
[DCC Error] Project1.dpr(98): E2250 There is no overloaded version of 'BinarySearch' that can be called with these arguments
and I don't understand where I made a mistake.
How can I solve it?