// We assume that when we insert, we respect the order, so we dont set Sorted=true
end;
function CompareOPT(Item1, Item2: Pointer): Integer;
begin
if TEscherOPTRecord(Item1).Row < TEscherOPTRecord(Item2).Row then Result:=-1 else if TEscherOPTRecord(Item1).Row > TEscherOPTRecord(Item2).Row then Result:=1 else Result:=0;
end;
procedure TEscherOPTCache.Sort;
begin
inherited Sort(CompareOPT);
Sorted:=true;
end;
function TEscherOPTCache.Find(const aItem:Integer ; var Index: integer): boolean;
Var
L, H, I, C: Integer;
begin
if not Sorted then Sort;
Result := False;
L := 0;
H := Count - 1;
while L <= H do
begin
I := (L + H) shr 1;
if Items[i].Row < aItem then C:=-1 else if Items[i].Row>aItem then C:=1 else C:=0;