您的位置:首页 > 移动开发 > Objective-C

六、Delphi 2009 泛型容器单元(Generics.Collections)[5]: TObject...<T> 系列

2009-11-03 11:43 417 查看
已经有了: TList<T>、TQueue<T>、TStack<T>、TDictionary<TKey,TValue>
为什么还有: TObjectList<T>、TObjectQueue<T>、TObjectStack<T>、TObjectDictionary<TKey,TValue> ?

还记得 Classes.TList 和 Contnrs.TObjectList 的主要区别吗?
如果元素是对象, Contnrs.TObjectList 在删除元素时会同时释放对象, 而 Classes.TList 不会.

同样在这里, Generics.Collections.TObjectList<T> 会同时释放对象, 而 Generics.Collections.TList<T> 不会.
其他也是一样.

dfm
object Form1: TForm1
Left = 0
Top = 0
Caption = 'Form1'
ClientHeight = 153
ClientWidth = 408
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
OnDestroy = FormDestroy
PixelsPerInch = 96
TextHeight = 13
object Panel1: TPanel
Left = 8
Top = 8
Width = 193
Height = 137
Caption = 'Panel1'
TabOrder = 0
object Button1: TButton
Left = 8
Top = 76
Width = 177
Height = 25
Caption = 'Button1'
TabOrder = 0
OnClick = Button1Click
end
object Button2: TButton
Left = 8
Top = 107
Width = 177
Height = 25
Caption = 'Button2'
TabOrder = 1
OnClick = Button2Click
end
end
object Panel2: TPanel
Left = 207
Top = 8
Width = 194
Height = 137
Caption = 'Panel2'
TabOrder = 1
object Button3: TButton
Left = 8
Top = 76
Width = 177
Height = 25
Caption = 'Button3'
TabOrder = 0
OnClick = Button3Click
end
object Button4: TButton
Left = 8
Top = 107
Width = 177
Height = 25
Caption = 'Button4'
TabOrder = 1
OnClick = Button4Click
end
end
end
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: