Show / Hide Table of Contents

Struct ReadOnlyDictionaryView<TKey, TInput, TOutput>

Represents lazily converted read-only dictionary.

Implements
IReadOnlyDictionary<TKey, TOutput>
IReadOnlyCollection<KeyValuePair<TKey, TOutput>>
IEnumerable<KeyValuePair<TKey, TOutput>>
IEnumerable
IEquatable<ReadOnlyDictionaryView<TKey, TInput, TOutput>>
Inherited Members
ValueType.ToString()
object.Equals(object, object)
object.GetType()
object.ReferenceEquals(object, object)
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 Source

ReadOnlyDictionaryView(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.

| Edit this page View Source

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 Source

Count

Count of key/value pairs.

Declaration
public int Count { get; }
Property Value
Type Description
int
| Edit this page View Source

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.

| Edit this page View Source

Keys

All dictionary keys.

Declaration
public IEnumerable<TKey> Keys { get; }
Property Value
Type Description
IEnumerable<TKey>
| Edit this page View Source

Values

All converted dictionary values.

Declaration
public IEnumerable<TOutput> Values { get; }
Property Value
Type Description
IEnumerable<TOutput>

Methods

| Edit this page View Source

ContainsKey(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.

| Edit this page View Source

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.

| Edit this page View Source

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
ValueType.Equals(object)
| Edit this page View Source

GetEnumerator()

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.

| Edit this page View Source

GetHashCode()

Returns hash code for the this view.

Declaration
public override int GetHashCode()
Returns
Type Description
int

The hash code of this view.

Overrides
ValueType.GetHashCode()
| Edit this page View Source

TryGetValue(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 Source

operator ==(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.

| Edit this page View Source

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.

Implements

IReadOnlyDictionary<TKey, TValue>
IReadOnlyCollection<T>
IEnumerable<T>
IEnumerable
IEquatable<T>

Extension Methods

BasicExtensions.IsBetween<T, TLowerBound, TUpperBound>(T, TLowerBound, TUpperBound)
BasicExtensions.IsOneOf<T>(T, ReadOnlySpan<T>)
Collection.ToAsyncEnumerator<TEnumerator, T>(TEnumerator, CancellationToken)
Collection.ToClassicEnumerator<TEnumerator, T>(TEnumerator)
Enumerator.Skip<TEnumerator, T>(ref TEnumerator, int)
ExpressionBuilder.Const<T>(T)
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)
Collection.Convert<TInput, TOutput>(IReadOnlyCollection<TInput>, Converter<TInput, TOutput>)
Dictionary.ConvertValues<TKey, TValue, TResult>(IReadOnlyDictionary<TKey, TValue>, Converter<TValue, TResult>)
Dictionary.IndexerGetter<TKey, TValue>(IReadOnlyDictionary<TKey, TValue>)
Dictionary.KeysGetter<TKey, TValue>(IReadOnlyDictionary<TKey, TValue>)
Dictionary.ValuesGetter<TKey, TValue>(IReadOnlyDictionary<TKey, TValue>)
  • Edit this page
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾