+ -
当前位置:首页 → 问答吧 → Generics.Collections TDictionary

Generics.Collections TDictionary

时间:2011-11-30

来源:互联网

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值?

作者: plushenkolxx   发布时间: 2011-11-30

Delphi(Pascal) code
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;

作者: simonhehe   发布时间: 2011-11-30

热门下载

更多