六、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
为什么还有: 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
相关文章推荐
- Delphi 2009 泛型容器单元(Generics.Collections)[5]: TObject...<T> 系列
- Delphi 2009 泛型容器单元(Generics.Collections)[1]: TList<T>
- 二、Delphi 2009 泛型容器单元(Generics.Collections)[1]: TList<T>
- Delphi 2009 泛型容器单元(Generics.Collections)[4]: TDictionary<T>
- 三、Delphi 2009 泛型容器单元(Generics.Collections)[2]: TQueue<T>
- Delphi 2009 泛型容器单元(Generics.Collections)[2]: TQueue<T>
- 四、Delphi 2009 泛型容器单元(Generics.Collections)[3]: TStack<T>
- Delphi 2009 泛型容器单元(Generics.Collections)[3]: TStack<T>
- 五、Delphi 2009 泛型容器单元(Generics.Collections): TDictionary<T>
- Delphi 2009 泛型容器单元(Generics.Collections)[4]: TDictionary<T>
- Delphi 2009 泛型容器单元(Generics.Collections)[1]: TList<T>
- Delphi 2009 泛型容器单元(Generics.Collections)[2]: TQueue
- [导入]Delphi 2009 泛型容器单元(Generics.Collections)[1]: TList
- 泛型容器单元(Generics.Collections)[2]: TQueue<T> 队列列表
- 泛型容器单元(Generics.Collections)[3]: TStack<T> 堆栈列表
- Delphi 的泛型和匿名函数:对 TObjectList<> 做排序
- 淺談怎么样运用Delphi 2009地泛型容器類別
- 淺談如何使用Delphi 2009的泛型容器類別
- 泛型系列<7>反转Sorted List里的内容
- C#中泛型容器Stack<T>