InternMap<K, V> Class

Provides the canonical value object corresponding to the key.

C#
public sealed class InternMap<K, V>
where K : notnull
where V : class

Type Parameters

K
notnull

The type of the key.

V
class

The type of the value.

Inheritance
InternMap<K, V>

Constructors

InternMap()

Initializes a new instance of the InternMap<K, V> class.

InternMap(int)

Initializes a new instance of the InternMap<K, V> class.

InternMap(int, int)

Initializes a new instance of the InternMap<K, V> class.

Methods

Intern(K, Func<K, V>)

Gets the canonical value object corresponding to the specified key object. If the canonical value object does not exist in the internal object pool, creates a new value object with the specified function.

Intern(K, Func<V>)

Gets the canonical value object corresponding to the specified key object. If the canonical value object does not exist in the internal object pool, creates a new value object with the specified supplier.

Equals(object) (Inherited from object)
GetHashCode() (Inherited from object)
GetType() (Inherited from object)
MemberwiseClone() (Inherited from object)
ToString() (Inherited from object)

Constructors Detail

InternMap()

Initializes a new instance of the InternMap<K, V> class.

C#
public InternMap()

InternMap(int)

Initializes a new instance of the InternMap<K, V> class.

C#
public InternMap(int initialCapacity)

Parameters

initialCapacity
int

The initial capacity.

InternMap(int, int)

Initializes a new instance of the InternMap<K, V> class.

C#
public InternMap(int initialCapacity, int concurrencyLevel)

Parameters

initialCapacity
int

The initial capacity.

concurrencyLevel
int

The concurrency level.

Methods Detail

Intern(K, Func<K, V>)

Gets the canonical value object corresponding to the specified key object. If the canonical value object does not exist in the internal object pool, creates a new value object with the specified function.

C#
public V Intern(K key, Func<K, V> newValue)

Parameters

key
K

The key object.

newValue
Func<K, V>

The function that returns a new value object corresponding to the specified argument.

Returns

V

The canonical value object.

Remarks

The specified function can be called concurrently with the equal keys if the multiple threads call this method. However, the canonical value object that this method returns is only one.

Intern(K, Func<V>)

Gets the canonical value object corresponding to the specified key object. If the canonical value object does not exist in the internal object pool, creates a new value object with the specified supplier.

C#
public V Intern(K key, Func<V> supplier)

Parameters

key
K

The key object.

supplier
Func<V>

The supplier that returns a new value object corresponding to the specified key object.

Returns

V

The canonical value object.

Remarks

The specified function can be called concurrently with the equal keys if the multiple threads call this method. However, the canonical value object that this method returns is only one.