InternMap<K, V> Class
Provides the canonical value object corresponding to the key.
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
-
Intern
Map<K, V>
Constructors
Intern |
Initializes a new instance of the InternMap<K, V> class. |
Intern |
Initializes a new instance of the InternMap<K, V> class. |
Intern |
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.
public InternMap()
InternMap(int)
Initializes a new instance of the InternMap<K, V> class.
public InternMap(int initialCapacity)
Parameters
- initialCapacity
- int
The initial capacity.
InternMap(int, int)
Initializes a new instance of the InternMap<K, V> class.
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.
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
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.
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
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.