Reference TDictionary<K, V>
Declared in Codebot.Collections.pas on line 176
TDictionary<K, V> holds key value pairs allowing items to be indexed by a key
TDictionary<K, V> = class(TObject)
public
type
{ TDictionary<K, V>.TKeyValue holds a key value pair }
TKeyValue = class
public
{ Create a key value pair given a key }
constructor Create(const Key: K);
{ The key }
property Key: K read FKey;
{ The value }
property Value: V read FValue write FValue;
end;
{ Get the enumerator for the dictionary }
function GetEnumerator: IEnumerator<TKeyValue>;
protected
{ Add a new key value pair to the dictionary }
procedure AddKeyValue(KeyValue: TKeyValue); virtual;
{ Create a new key value pair for a key }
function CreateKeyValue(const Key: K): TKeyValue; virtual;
{ Destroy a key value pair when it is removed }
procedure DestroyKeyValue(KeyValue: TKeyValue); virtual;
{ Change the value of an existing key value pair }
procedure ChangeKeyValue(KeyValue: TKeyValue; Value: V); virtual;
{ Return a default value if no key exists }
function DefaultValue: V; virtual;
{ When true key values will automatically be created when a value is
requested if it doesn't exist }
property AutoKey: Boolean read FAutoKey write FAutoKey;
public
{ Create the dictionary }
constructor Create;
{ Clear the dictionary and destroy it }
destructor Destroy; override;
{ Remove an item by key }
procedure Remove(const Key: K);
{ Remove all items from the dictionary }
procedure Clear;
{ Returns true if the key is in the dictionary }
function KeyExists(const Key: K): Boolean;
{ Used to compare keys }
property Comparer: TCompare<K> read FComparer write FComparer;
{ Items indexed by integer }
property Items[Index: Integer]: TKeyValue read GetItem;
{ Keys indexed by integer }
property Keys[Index: Integer]: K read GetKey;
{ Values indexed by key }
property Values[const Key: K]: V read GetValue write SetValue; default;
{ Number of key value pairs }
property Count: Integer read GetCount;
end;See also
TCompare<T> in Codebot.System.pas