KGy SOFT

CacheTKey, TValueTouch Method

KGy SOFT Core Libraries Help
Renews the value with the specified key in the evaluation order.

Namespace:  KGySoft.Collections
Assembly:  KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 5.0.0
Syntax

public void Touch(
	TKey key
)

Parameters

key
Type: TKey
The key of the item to renew.
Exceptions

Remarks

CacheTKey, TValue maintains an evaluation order for the stored elements. When the CacheTKey, TValue is full (that is when Count equals to Capacity), then adding a new element will drop the element, which is the first one in the evaluation order. By calling this method, the element with the specified key will be sent to the back in the evaluation order.

When Behavior is RemoveLeastRecentUsedElement (which is the default behavior), then whenever an existing element is accessed in the CacheTKey, TValue, then it will be touched internally.

This method approaches an O(1) operation.

See Also

Reference