From RAD Studio VCL Reference
Jump to: navigation, search

Delphi Information

From Generics.Collections.pas

TDictionary<Generics.Collections.TObjectDictionary<TKey,TValue>.TKey,Generics.Collections.TObjectDictionary<TKey,TValue>.TValue> = class(TEnumerable<TPair<Generics.Collections.TObjectDictionary<TKey,TValue>.TKey,Generics.Collections.TObjectDictionary<TKey,TValue>.TValue>>)

Unit: Generics.Collections

Type: class

Inherited Class Members: Generics.Collections.TDictionary Members

Class Properties: Generics.Collections.TDictionary Properties

Class Methods: Generics.Collections.TDictionary Methods

Class Constructors & Destructors: Generics.Collections.TDictionary Constructors

Class Events: Generics.Collections.TDictionary Events


Collection of key-value pairs.

TDictionary represents a generic collection of key-value pairs.

This class provides a mapping from a collection of keys to a collection of values. When you create a TDictionary object, you can specify various combinations of initial capacity, equality operation, and initial content.

You can add a key that is associated with a corresponding value with the Add or AddOrSetValue methods. You can remove entries with Remove or Clear, which removes all key-value pairs. Adding or removing a key-value pair and looking up a key are efficient, close to O(1), because keys are hashed. A key must not be nil (though a value may be nil) and there must be an equality comparison operation for keys.

You can test for the presence or keys and values with the TryGetValue, ContainsKey and ContainsValue methods.

The Items property lists all Count dictionary entries. You can also set and get values by indexing the Items property. Setting the value this way overwrites any existing value.

The class TObjectDictionary inherits from TDictionary and provides an automatic mechanism for freeing objects removed from dictionary entries.

See Also