Development · Native API migration preview · Coverage validation in progress Published release →

API Browser

Method

GetOrInsert

func GetOrInsert<T>(value: T) -> T

Declaring type: MutableSetExtensions
Module: System.Collections
Assembly: System.Runtime.dll

Extension from MutableSetExtensions.GetOrInsert

Returns the stored equivalent value, inserting the supplied value when absent.

Parameters

Name Type Description
self MutableSet<T> The mutable set to query or update.
value T The eagerly evaluated candidate, compared using the set's own policy.

Return value

T

The stored equivalent value, preserving its identity, or the inserted candidate.

Remarks

Does not replace an equivalent element. Requires exclusive external synchronization when shared; the lookup and insertion are not an atomic transaction.