zoukankan      html  css  js  c++  java
  • Delphi 泛型对象类

     {
    很早就写了. 只针对delphixe 以上的版本可用.
      希望不是自己在造轮子. 
    }
    1
    unit U_ClassUtility; 2 3 interface 4 uses generics.defaults,DateUtils,Classes,SysUtils,Windows, generics.collections; 5 6 type 7 TGenericList<T> = class 8 private 9 fList : Tlist<T>; 10 procedure SetList(const Value: TList<T>); 11 public 12 procedure clear; 13 procedure Add(Aobj : T); 14 15 constructor Create; 16 destructor Destroy; override; 17 property List : TList<T> read FList write SetList; 18 end; 19 20 implementation 21 { TGenericList<T> } 22 23 procedure TGenericList<T>.Add(Aobj: T); 24 begin 25 fList.Add(Aobj); 26 end; 27 28 procedure TGenericList<T>.clear; 29 var 30 i : Integer; 31 begin 32 for I := 0 to fList.Count -1 do 33 TObject(fList.Items[i]).Free; 34 35 fList.Clear; 36 end; 37 38 constructor TGenericList<T>.Create; 39 begin 40 fList := TList<T>.Create; 41 end; 42 43 destructor TGenericList<T>.Destroy; 44 begin 45 clear; 46 fList.Free; 47 inherited; 48 end; 49 50 procedure TGenericList<T>.SetList(const Value: TList<T>); 51 begin 52 FList := Value; 53 end; 54 55 end.
  • 相关阅读:
    Tinkoff Challenge
    Uva 12298 超级扑克2
    BZOJ 1031 字符加密
    HDU 4944 逆序数对
    51nod 1215 数组的宽度
    LA 3126 出租车
    LA 3415 保守的老师
    51nod 1275 连续子段的差异
    Uva 11419 我是SAM
    LA 4043 最优匹配
  • 原文地址:https://www.cnblogs.com/starluck/p/3643115.html
Copyright © 2011-2022 走看看