Модератор: Модераторы
THashDjb2ForAnsiString = type helper for AnsiString
  function GetHash: THash32; inline;
end;
function Djb2(P: PByte; Size: Int64): THash64;
begin
  Result := 5381;
  while Size > 0 do begin
    Result := ((Result shl 5) + Result) + P^;
    Inc(P);
   Dec(Size);
  end;
end;
function THashDjb2ForAnsiString.GetHash: THash32;
begin
  Result := Djb2(PByte(@Self[1]), Length(Self));
end;
generic THashMap<TKey, TValue> = object
  ...
end;
Лекс Айрин писал(а):dedm0zaj, почему? Очень удобная фишка. Посмотрим, как оно будет реализовано.
type
  TFileStream = class(THandleStream)
  Private
    FFileName : UnicodeString;
  public
    constructor Create(const AFileName: UnicodeString; Mode: Word);
    constructor Create(const AFileName: UnicodeString; Mode: Word; Rights: Cardinal);
    destructor Destroy; override;
    property FileName : UnicodeString Read FFilename;
  end; 
  
  
........
constructor TFileStream.Create(const AFileName: UnicodeString; Mode: Word);
begin
  Create(AFileName,Mode,438);
end;
constructor TFileStream.Create(const AFileName: UnicodeString; Mode: Word; Rights: Cardinal);
begin
  FFileName:=AFileName;
  If (Mode and fmCreate) > 0 then
    FHandle:=FileCreate(AFileName,Mode,Rights)
  else
    FHAndle:=FileOpen(AFileName,Mode);
  If (THandle(FHandle)=feInvalidHandle) then
    If Mode=fmcreate then
      raise EFCreateError.createfmt(SFCreateError,[AFileName])
    else
      raise EFOpenError.Createfmt(SFOpenError,[AFilename]);
end;  Дож писал(а):А замыкания есть с 2.6.0 («is nested» ссылки)
http://wiki.freepascal.org/FPC_New_Feat ... _variables
http://www.freepascal.org/docs-html/ref/refse17.html
   auto lambda = [](auto x) {
      return x;
   };
типа используем
        writeln(lambda("Hello generic lambda!\n"));
Вернуться в Free Pascal Compiler
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 1