Generics.Collections TDictionary

plushenkolxx 2011-11-30 12:06:34
Delphi Generics.Collections单元中
TDictionary<TKey,TValue> = class(TEnumerable<TPair<TKey,TValue>>)
private
type
TItem = record
HashCode: Integer;
Key: TKey;
Value: TValue;
end;
TItemArray = array of TItem;

如何改变 Dictionary中的key值?
...全文
97 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
simonhehe 2011-11-30
  • 打赏
  • 举报
回复
var
a : TDictionary<integer,integer>;
b : TPair<integer,integer>;
begin
a := TDictionary<integer,integer>.create;
try
a.Add(1, 1);

b.Key := 1;
b.Value := a.Items[b.Key];

a.Remove(b.Key);

b.Key := 2;
a.Add(b.Key, b.Value);
Caption := IntToStr(a.Items[2]);
finally
a.Free;
end;

16,748

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 语言基础/算法/系统设计
社区管理员
  • 语言基础/算法/系统设计社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧