Show/Hide Toolbars

RiverSoftAVG Products Help

Navigation: Code Documentation > RSCommon > RSGenerics.Collections > Classes

TRSDictionary<TKey,TValue> Class

Scroll Prev Top Next More

Collection of key-value pairs.

TRSDictionary 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 TRSDictionary 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 TRSDictionary<TKey,TValue> class was created to address problems in the TDictionary class that prevented subclassing from the class. The TRSHashTable<TKey,TValue> needed some changes (as of XE4) in order to properly mimic the older TGHashTable class from RiverSoftAVG:

moved FItems to protected

moved DoAdd to protected and made it virtual

moved DoSetValue to protected and made it virtual

moved DoRemove to protected and made it virtual

Changed Remove from procedure to function

Namespace: RSGenerics.Collections

Type Parameters



public method


Remove key-value pair.

Remove removes the given key and its associated value from the dictionary. No exception is thrown if the key is not in the dictionary. This is an O(1) operation.

An     OnKeyNotify event and an     OnValueNotify event occur indicating an entry was removed from the dictionary.

public method


Returns the content of the dictionary as an array.
 (Overrides RSGenerics.Collections.TRSEnumerable<T>.ToArray.)

protected method


Converts the enumerable container's items into an equivalent TArray of items. (Inherited from RSGenerics.Collections.TRSEnumerable<T>.)

public method


Reduce capacity to current number of entries.

TrimExcess changes the capacity to the number of dictionary entries, held in Count.

This method rehashes the internal hash table to save space. This is only useful after a lot of items have been deleted from the dictionary.

public method


Try to get value for key.

TryGetValue returns true if the given key is in the dictionary and provides its value in Value. Otherwise, it returns false and Value is set to the default value type of TValue. No exception is raised if the key is not in the dictionary. This is an O(1) operation.

protected method


Triggers an     OnValueNotify event with the given parameters.

Call ValueNotify to trigger an OnValueNotify event with the given parameters.

The meaning of the parameters is given in the following table:


The Value that is added, removed or extracted.


The action that the Value undergoes, which is of type TCollectionNotification.


RiverSoftAVG Products Help © 1996-2016 Thomas G. Grubb