Reputation: 133
I use TDictionary to handle large volumes of data. How can I detect the moment when the size increases TDictionary?
Upvotes: 2
Views: 619
Reputation: 49
In recent versions of Delphi there is the Capacity property:
property Capacity: Integer read GetCapacity write SetCapacity;
But you still don't get to know when the object grows capacity on its own.
You can though set the Capacity large enough to cover your needs, Then use the TrimExcess method to set the capacity to actual number of entries.
Upvotes: 0
Reputation: 612993
If you wish to detect when the underlying private storage is grown, then you cannot. That is handled by the private methods SetCapacity
and Grow
, and the class provides no external hook.
You can detect key and value modifications using the OnKeyNotify
and OnValueNotify
events. The OnKeyNotify
event fires with notification parameter of cnAdded
when a new key is added.
Upvotes: 2