ugeneric10.pp 458 B

123456789101112131415161718192021222324252627282930
  1. unit ugeneric10;
  2. {$mode objfpc}
  3. interface
  4. type
  5. generic TList<_T>=class(TObject)
  6. type public
  7. TCompareFunc = function(const Item1, Item2: _T): Integer;
  8. var public
  9. data : _T;
  10. procedure Add(item: _T);
  11. procedure Sort(compare: TCompareFunc);
  12. end;
  13. implementation
  14. procedure TList.Add(item: _T);
  15. begin
  16. data:=item;
  17. end;
  18. procedure TList.Sort(compare: TCompareFunc);
  19. begin
  20. if compare(data, 20) <= 0 then
  21. halt(1);
  22. end;
  23. end.