Struct ReadOnlyDictionaryView<TKey, TInput, TOutput>
Represents lazily converted read-only dictionary.
Implements
Inherited Members
Namespace: DotNext.Collections.Generic
Assembly: DotNext.dll
Syntax
public readonly struct ReadOnlyDictionaryView<TKey, TInput, TOutput> : IReadOnlyDictionary<TKey, TOutput>, IReadOnlyCollection<KeyValuePair<TKey, TOutput>>, IEnumerable<KeyValuePair<TKey, TOutput>>, IEnumerable, IEquatable<ReadOnlyDictionaryView<TKey, TInput, TOutput>>
Type Parameters
Name | Description |
---|---|
TKey | Type of dictionary keys. |
TInput | Type of values in the source dictionary. |
TOutput | Type of values in the converted dictionary. |
Remarks
Initializes a new lazily converted view.
Constructors
| Edit this page View SourceReadOnlyDictionaryView(IReadOnlyDictionary<TKey, TInput>, Converter<TInput, TOutput>)
Initializes a new lazily converted view.
Declaration
public ReadOnlyDictionaryView(IReadOnlyDictionary<TKey, TInput> dictionary, Converter<TInput, TOutput> mapper)
Parameters
Type | Name | Description |
---|---|---|
IReadOnlyDictionary<TKey, TInput> | dictionary | Read-only dictionary to convert. |
Converter<TInput, TOutput> | mapper | Value converter. |
ReadOnlyDictionaryView(IReadOnlyDictionary<TKey, TInput>, Func<TInput, TOutput>)
Represents lazily converted read-only dictionary.
Declaration
public ReadOnlyDictionaryView(IReadOnlyDictionary<TKey, TInput> dictionary, Func<TInput, TOutput> mapper)
Parameters
Type | Name | Description |
---|---|---|
IReadOnlyDictionary<TKey, TInput> | dictionary | Read-only dictionary to convert. |
Func<TInput, TOutput> | mapper | Value converter. |
Remarks
Initializes a new lazily converted view.
Properties
| Edit this page View SourceCount
Count of key/value pairs.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
int |
this[TKey]
Gets value associated with the key and convert it.
Declaration
public TOutput this[TKey key] { get; }
Parameters
Type | Name | Description |
---|---|---|
TKey | key | The key of the element to get. |
Property Value
Type | Description |
---|---|
TOutput | The converted value associated with the key. |
Exceptions
Type | Condition |
---|---|
KeyNotFoundException | The requested key doesn't exist. |
Keys
All dictionary keys.
Declaration
public IEnumerable<TKey> Keys { get; }
Property Value
Type | Description |
---|---|
IEnumerable<TKey> |
Values
All converted dictionary values.
Declaration
public IEnumerable<TOutput> Values { get; }
Property Value
Type | Description |
---|---|
IEnumerable<TOutput> |
Methods
| Edit this page View SourceContainsKey(TKey)
Determines whether the wrapped dictionary contains an element with the specified key.
Declaration
public bool ContainsKey(TKey key)
Parameters
Type | Name | Description |
---|---|---|
TKey | key | The key to locate in the dictionary. |
Returns
Type | Description |
---|---|
bool | true if the key exists in the wrapped dictionary; otherwise, false. |
Equals(ReadOnlyDictionaryView<TKey, TInput, TOutput>)
Determines whether two converted dictionaries are same.
Declaration
public bool Equals(ReadOnlyDictionaryView<TKey, TInput, TOutput> other)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlyDictionaryView<TKey, TInput, TOutput> | other | Other dictionary to compare. |
Returns
Type | Description |
---|---|
bool | true if this view wraps the same source dictionary and contains the same converter as other view; otherwise, false. |
Equals(object?)
Determines whether two converted dictionaries are same.
Declaration
public override bool Equals(object? other)
Parameters
Type | Name | Description |
---|---|---|
object | other | Other dictionary to compare. |
Returns
Type | Description |
---|---|
bool | true if this view wraps the same source dictionary and contains the same converter as other view; otherwise, false. |
Overrides
| Edit this page View SourceGetEnumerator()
Returns enumerator over key/value pairs in the wrapped dictionary and performs conversion for each value in the pair.
Declaration
public IEnumerator<KeyValuePair<TKey, TOutput>> GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator<KeyValuePair<TKey, TOutput>> | The enumerator over key/value pairs. |
GetHashCode()
Returns hash code for the this view.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int | The hash code of this view. |
Overrides
| Edit this page View SourceTryGetValue(TKey, out TOutput)
Returns the converted value associated with the specified key.
Declaration
public bool TryGetValue(TKey key, out TOutput value)
Parameters
Type | Name | Description |
---|---|---|
TKey | key | The key whose value to get. |
TOutput | value | The converted value associated with the specified key, if the key is found; otherwise, the default value for the type of the value parameter. This parameter is passed uninitialized. |
Returns
Type | Description |
---|---|
bool | true, if the dictionary contains the specified key; otherwise, false. |
Operators
| Edit this page View Sourceoperator ==(in ReadOnlyDictionaryView<TKey, TInput, TOutput>, in ReadOnlyDictionaryView<TKey, TInput, TOutput>)
Determines whether two views are same.
Declaration
public static bool operator ==(in ReadOnlyDictionaryView<TKey, TInput, TOutput> first, in ReadOnlyDictionaryView<TKey, TInput, TOutput> second)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlyDictionaryView<TKey, TInput, TOutput> | first | The first dictionary to compare. |
ReadOnlyDictionaryView<TKey, TInput, TOutput> | second | The second dictionary to compare. |
Returns
Type | Description |
---|---|
bool | true if the first view wraps the same source dictionary and contains the same converter as the second view; otherwise, false. |
operator !=(in ReadOnlyDictionaryView<TKey, TInput, TOutput>, in ReadOnlyDictionaryView<TKey, TInput, TOutput>)
Determines whether two views are not same.
Declaration
public static bool operator !=(in ReadOnlyDictionaryView<TKey, TInput, TOutput> first, in ReadOnlyDictionaryView<TKey, TInput, TOutput> second)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlyDictionaryView<TKey, TInput, TOutput> | first | The first dictionary to compare. |
ReadOnlyDictionaryView<TKey, TInput, TOutput> | second | The second collection to compare. |
Returns
Type | Description |
---|---|
bool | true if the first view wraps the different source dictionary and contains the different converter as the second view; otherwise, false. |