ThreadSafeDictionaryTKey, TValuePreserveMergedKeys Property

Gets or sets whether keys of entries that have already been merged into the faster lock-free storage are preserved even when their value is removed.
Default value: .

Definition

Namespace: KGySoft.Collections
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 10.0.0
C#
public bool PreserveMergedKeys { get; set; }

Property Value

Boolean

Remarks

If the possible number of keys in this ThreadSafeDictionaryTKey, TValue is known to be a limited value, then this property can be set to , so once the values have been merged into the faster lock-free storage, their entry is not removed anymore even if the corresponding value is deleted. This ensures that removing and re-adding a value with the same key again and again remains a lock-free operation.

  Note

Do not set this property to , if the number of the possibly added keys is not limited.

This property can be set to even if keys are never removed so it is not checked before a merge operation whether the amount of deleted items exceeds a specific limit.

If this property is , then the already merged keys are not removed even when calling the Clear method. The memory of the deleted entries can be freed by explicitly calling the TrimExcess method, whereas to remove all allocated entries you can call the Reset method.

Even if this property is , the removed keys are not dropped immediately. Unused keys are removed during a merge operation and only when their number exceeds a specific limit. You can call the TrimExcess method to force removing unused keys on demand.

See Also