Einzelnen Beitrag anzeigen

NicoDE
(Gast)

n/a Beiträge
 
#9

Re: pointer to an array in D und C++

  Alt 19. Mär 2004, 12:47
Zitat von Virchov:
Son Schheissforum!
Mäßige Dich bitte.

Delphi-Quellcode:
type
  PBooleanArray = ^TBooleanArray;
  TBooleanArray = array [0..High(Integer) - 1] of Boolean;

function BinImgMatchProMile(const BinImg1, BinImg2: TBooleanArray;
  nElements: Integer; out BinImgPlus, BinImgMinus: TBooleanArray): Integer;
  cdecl;
var
  idx: Integer;
  MatchCounter: Integer;
begin
  Result := 0;
  if (nElements > 0) then
  begin
    MatchCounter := 0;
    // calculations
    for idx := 0 to nElements - 1 do
    begin
      // local initialisation
      BinImgPlus[idx] := False;
      BinImgMinus[idx] := False;
      // Find out what to do for this element
      if BinImg1[idx] = BinImg2[idx] then
        // Got a match in case BinImg1 = BinImg2
        Inc(MatchCounter)
      else if BinImg1[idx] and not BinImg2[idx] then
        // Got positive difference in case BinImg1 > BinImg2
        BinImgPlus[idx] := True
      else if BinImg2[idx] and not BinImg1[idx] then
        // Got negatice difference in case BinImg1 < BinImg2
        BinImgMinus[idx] := True;
    end;
    Result := Int64(MatchCounter) * 1000 div nElements;
  end;
end;
  Mit Zitat antworten Zitat