Show / Hide Table of Contents

Class ConcurrentTypeMap<TValue>

Represents thread-safe implementation of ITypeMap<TValue> interface.

Inheritance
object
ConcurrentTypeMap<TValue>
Implements
ITypeMap<TValue>
IReadOnlyTypeMap<TValue>
IEnumerable<TValue>
IEnumerable
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: DotNext.Collections.Specialized
Assembly: DotNext.dll
Syntax
public class ConcurrentTypeMap<TValue> : ITypeMap<TValue>, IReadOnlyTypeMap<TValue>, IEnumerable<TValue>, IEnumerable
Type Parameters
Name Description
TValue

The type of the value.

Constructors

| Edit this page View Source

ConcurrentTypeMap()

Initializes a new map of recommended capacity.

Declaration
public ConcurrentTypeMap()
| Edit this page View Source

ConcurrentTypeMap(int)

Initializes a new map.

Declaration
public ConcurrentTypeMap(int capacity)
Parameters
Type Name Description
int capacity

The initial capacity of the map.

Exceptions
Type Condition
ArgumentOutOfRangeException

capacity is less than zero.

Methods

| Edit this page View Source

AddOrUpdate<TKey>(TValue)

Adds a value to the map if the key does not already exist, or updates the existing value.

Declaration
public bool AddOrUpdate<TKey>(TValue value)
Parameters
Type Name Description
TValue value

The value associated with the type.

Returns
Type Description
bool

true if value is added; false if the existing value is updated with value.

Type Parameters
Name Description
TKey

The type acting as a key.

| Edit this page View Source

Clear()

Removes all elements from this map.

Declaration
public void Clear()
| Edit this page View Source

ContainsKey<TKey>()

Determines whether the map has association between the value and the specified type.

Declaration
public bool ContainsKey<TKey>()
Returns
Type Description
bool

true if there is a value associated with TKey; otherwise, false.

Type Parameters
Name Description
TKey

The type acting as a key.

| Edit this page View Source

GetEnumerator()

Gets enumerator over the values.

Declaration
public ConcurrentTypeMap<TValue>.Enumerator GetEnumerator()
Returns
Type Description
ConcurrentTypeMap<TValue>.Enumerator

The enumerator over the values.

| Edit this page View Source

GetOrAdd<TKey>(TValue, out bool)

Adds a value to the map if the key does not already exist. Returns the new value, or the existing value if the key already exists.

Declaration
public TValue GetOrAdd<TKey>(TValue value, out bool added)
Parameters
Type Name Description
TValue value

The value associated with the type.

bool added

true if the value is added; false if the value is already exist.

Returns
Type Description
TValue

The existing value; or value if added.

Type Parameters
Name Description
TKey

The type acting as a key.

| Edit this page View Source

Remove<TKey>()

Attempts to remove the value from the map.

Declaration
public bool Remove<TKey>()
Returns
Type Description
bool

true if the element successfully removed; otherwise, false.

Type Parameters
Name Description
TKey

The type acting as a key.

| Edit this page View Source

Remove<TKey>(out TValue)

Attempts to remove the value from the map.

Declaration
public bool Remove<TKey>(out TValue value)
Parameters
Type Name Description
TValue value

The value of the removed element.

Returns
Type Description
bool

true if the element successfully removed; otherwise, false.

Type Parameters
Name Description
TKey

The type acting as a key.

| Edit this page View Source

Set<TKey>(TValue)

Associates the value with the specified type.

Declaration
public void Set<TKey>(TValue value)
Parameters
Type Name Description
TValue value

The value to set.

Type Parameters
Name Description
TKey

The type acting as a key.

| Edit this page View Source

Set<TKey>(TValue, out TValue)

Replaces the existing value with a new value.

Declaration
public bool Set<TKey>(TValue newValue, out TValue oldValue)
Parameters
Type Name Description
TValue newValue

A new value.

TValue oldValue

The replaced value.

Returns
Type Description
bool

true if value is replaced; false if a new value is added without replacement.

Type Parameters
Name Description
TKey

The type acting as a key.

| Edit this page View Source

TryAdd<TKey>(TValue)

Attempts to associate a value with the type.

Declaration
public bool TryAdd<TKey>(TValue value)
Parameters
Type Name Description
TValue value

The value associated with the type.

Returns
Type Description
bool

true if the value is added; otherwise, false.

Type Parameters
Name Description
TKey

The type acting as a key.

| Edit this page View Source

TryGetValue<TKey>(out TValue)

Attempts to get the value associated with the specified type.

Declaration
public bool TryGetValue<TKey>(out TValue value)
Parameters
Type Name Description
TValue value

The value associated with the type.

Returns
Type Description
bool

true if there is a value associated with TKey; otherwise, false.

Type Parameters
Name Description
TKey

The type acting as a key.

Implements

ITypeMap<TValue>
IReadOnlyTypeMap<TValue>
IEnumerable<T>
IEnumerable

Extension Methods

BasicExtensions.As<T>(T)
BasicExtensions.GetUserData<T>(T)
BasicExtensions.IsBetween<T, TLowerBound, TUpperBound>(T, TLowerBound, TUpperBound)
BasicExtensions.IsOneOf<T>(T, ReadOnlySpan<T>)
ExpressionBuilder.Const<T>(T)
AsyncLockAcquisition.AcquireLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireLockAsync<T>(T, TimeSpan, CancellationToken)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, TimeSpan, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, bool, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, bool, TimeSpan, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, TimeSpan, CancellationToken)
LockAcquisition.AcquireReadLock<T>(T)
LockAcquisition.AcquireReadLock<T>(T, TimeSpan)
LockAcquisition.AcquireUpgradeableReadLock<T>(T)
LockAcquisition.AcquireUpgradeableReadLock<T>(T, TimeSpan)
LockAcquisition.AcquireWriteLock<T>(T)
LockAcquisition.AcquireWriteLock<T>(T, TimeSpan)
Collection.Append<T>(IEnumerable<T>, params T[])
Collection.Copy<T>(IEnumerable<T>, int, MemoryAllocator<T>?)
Collection.ElementAt<T>(IEnumerable<T>, int, out T)
Collection.FirstOrNone<T>(IEnumerable<T>)
Collection.ForEachAsync<T>(IEnumerable<T>, Func<T, CancellationToken, ValueTask>, CancellationToken)
Collection.ForEach<T>(IEnumerable<T>, Action<T>)
Collection.LastOrNone<T>(IEnumerable<T>)
Collection.Prepend<T>(IEnumerable<T>, params T[])
Collection.SequenceHashCode<T>(IEnumerable<T>, bool)
Collection.ToAsyncEnumerable<T>(IEnumerable<T>)
Collection.ToString<T>(IEnumerable<T>, string, string)
Enumerator.GetAsyncEnumerator<T>(IEnumerable<T>, CancellationToken)
  • Edit this page
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾