Struct ReadOnlyDictionaryView<K, I, O>
Represents lazily converted read-only dictionary.
Namespace: DotNext.Collections.Generic
Assembly: DotNext.dll
Syntax
public struct ReadOnlyDictionaryView<K, I, O> : IReadOnlyDictionary<K, O>, IEquatable<ReadOnlyDictionaryView<K, I, O>>
Type Parameters
Name | Description |
---|---|
K | Type of dictionary keys. |
I | Type of values in the source dictionary. |
O | Type of values in the converted dictionary. |
Constructors
| Improve this Doc View SourceReadOnlyDictionaryView(IReadOnlyDictionary<K, I>, ValueFunc<I, O>)
Initializes a new lazily converted view.
Declaration
public ReadOnlyDictionaryView(IReadOnlyDictionary<K, I> dictionary, in ValueFunc<I, O> mapper)
Parameters
Type | Name | Description |
---|---|---|
IReadOnlyDictionary<K, I> | dictionary | Read-only dictionary to convert. |
ValueFunc<I, O> | mapper | Value converter. |
Properties
| Improve this Doc View SourceCount
Count of key/value pairs.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
Int32 |
Item[K]
Gets value associated with the key and convert it.
Declaration
public O this[K key] { get; }
Parameters
Type | Name | Description |
---|---|---|
K | key | The key of the element to get. |
Property Value
Type | Description |
---|---|
O | The converted value associated with the key. |
Keys
All dictionary keys.
Declaration
public IEnumerable<K> Keys { get; }
Property Value
Type | Description |
---|---|
IEnumerable<K> |
Values
All converted dictionary values.
Declaration
public IEnumerable<O> Values { get; }
Property Value
Type | Description |
---|---|
IEnumerable<O> |
Methods
| Improve this Doc View SourceContainsKey(K)
Determines whether the wrapped dictionary contains an element with the specified key.
Declaration
public bool ContainsKey(K key)
Parameters
Type | Name | Description |
---|---|---|
K | key | The key to locate in the dictionary. |
Returns
Type | Description |
---|---|
Boolean | true if the key exists in the wrapped dictionary; otherwise, false. |
Equals(ReadOnlyDictionaryView<K, I, O>)
Determines whether two converted dictionaries are same.
Declaration
public bool Equals(ReadOnlyDictionaryView<K, I, O> other)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlyDictionaryView<K, I, O> | other | Other dictionary to compare. |
Returns
Type | Description |
---|---|
Boolean | 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 |
---|---|
Boolean | true if this view wraps the same source dictionary and contains the same converter as other view; otherwise, false. |
GetEnumerator()
Returns enumerator over key/value pairs in the wrapped dictionary and performs conversion for each value in the pair.
Declaration
public IEnumerator<KeyValuePair<K, O>> GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator<KeyValuePair<K, O>> | The enumerator over key/value pairs. |
GetHashCode()
Returns hash code for the this view.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Int32 | The hash code of this view. |
TryGetValue(K, out O)
Returns the converted value associated with the specified key.
Declaration
public bool TryGetValue(K key, out O value)
Parameters
Type | Name | Description |
---|---|---|
K | key | The key whose value to get. |
O | value | The converted value associated with the specified key, if the key is found; otherwise, the langword_csharp_default value for the type of the value parameter. This parameter is passed uninitialized. |
Returns
Type | Description |
---|---|
Boolean | true, if the dictionary contains the specified key; otherwise, false. |
Operators
| Improve this Doc View SourceEquality(ReadOnlyDictionaryView<K, I, O>, ReadOnlyDictionaryView<K, I, O>)
Determines whether two views are same.
Declaration
public static bool operator ==(ReadOnlyDictionaryView<K, I, O> first, ReadOnlyDictionaryView<K, I, O> second)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlyDictionaryView<K, I, O> | first | The first dictionary to compare. |
ReadOnlyDictionaryView<K, I, O> | second | The second dictionary to compare. |
Returns
Type | Description |
---|---|
Boolean | true if the first view wraps the same source dictionary and contains the same converter as the second view; otherwise, false. |
Inequality(ReadOnlyDictionaryView<K, I, O>, ReadOnlyDictionaryView<K, I, O>)
Determines whether two views are not same.
Declaration
public static bool operator !=(ReadOnlyDictionaryView<K, I, O> first, ReadOnlyDictionaryView<K, I, O> second)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlyDictionaryView<K, I, O> | first | The first dictionary to compare. |
ReadOnlyDictionaryView<K, I, O> | second | The second collection to compare. |
Returns
Type | Description |
---|---|
Boolean | true if the first view wraps the different source dictionary and contains the different converter as the second view; otherwise, false. |