TCollections.CreateDictionary<TKey,TValue> Method

Overloads

CreateDictionary<TKey,TValue>

Creates a hash-based dictionary.

CreateDictionary<TKey,TValue>(IEqualityComparer<TKey>)

Creates a hash-based dictionary that uses an equality comparer for key lookup.

CreateDictionary<TKey,TValue>

Creates a hash-based dictionary.

Delphi
class function CreateDictionary<TKey,TValue>: IDictionary<TKey,TValue>; overload; static;

Type Parameters

TKey

The type of keys in the dictionary.

TValue

The type of values in the dictionary.

Returns

IDictionary<TKey, TValue>

A new IDictionary<TKey,TValue> instance.

Examples

delphi

  var
    Ages: IDictionary<string,Integer>;
  begin
    Ages := TCollections.CreateDictionary<string,Integer>;
    Ages.Add('Ada', 36);
  end;

CreateDictionary<TKey,TValue>(IEqualityComparer<TKey>)

Creates a hash-based dictionary that uses an equality comparer for key lookup.

Delphi
class function CreateDictionary<TKey,TValue>(const Comparer: IEqualityComparer<TKey>): IDictionary<TKey,TValue>; overload; static;

Type Parameters

TKey

The type of keys in the dictionary.

TValue

The type of values in the dictionary.

Parameters

Comparer
IEqualityComparer<TKey>

The IEqualityComparer<TKey> used for dictionary keys.

Returns

IDictionary<TKey, TValue>

A new IDictionary<TKey,TValue> instance.

Remarks

If Comparer is nil, the dictionary uses the default equality comparer for type TKey.