ThreadSafeHashSetTPreserveMergedItems Property

Gets or sets whether items that have already been merged into the faster lock-free storage are preserved even when they are deleted.
Default value: .

Definition

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

Property Value

Boolean

Remarks

If the possible number of items in this ThreadSafeHashSetT is known to be a limited value, then this property can be set to , so once the items have been merged into the faster lock-free storage, their entry is not removed anymore even if they are deleted. This ensures that removing and re-adding an item again and again remains a lock-free operation.

  Note

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

This property can be set to even if items 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 items 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 items are not dropped immediately. Unused items 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 items on demand.

See Also