7 instantiations of ImmutableSegmentedDictionary
Microsoft.CodeAnalysis.CodeStyle (7)
src\Dependencies\Collections\ImmutableSegmentedDictionary`2.cs (2)
73
public static readonly ImmutableSegmentedDictionary<TKey, TValue> Empty =
new
(new SegmentedDictionary<TKey, TValue>());
283
return new
ImmutableSegmentedDictionary
<TKey, TValue>(new SegmentedDictionary<TKey, TValue>(keyComparer));
src\Dependencies\Collections\ImmutableSegmentedDictionary`2+PrivateMarshal.cs (4)
24
return new
ImmutableSegmentedDictionary
<TKey, TValue>(dictionary);
33
return new
ImmutableSegmentedDictionary
<TKey, TValue>(dictionary);
42
return new
ImmutableSegmentedDictionary
<TKey, TValue>(dictionary);
51
=> dictionary is not null ? new
ImmutableSegmentedDictionary
<TKey, TValue>(dictionary) : default;
src\Dependencies\Collections\ImmutableSegmentedDictionary`2+ValueBuilder.cs (1)
229
_dictionary = new
ImmutableSegmentedDictionary
<TKey, TValue>(ReadOnlyDictionary);
179 references to ImmutableSegmentedDictionary
Microsoft.CodeAnalysis.CodeStyle (179)
src\Compilers\Core\Portable\Collections\DictionaryExtensions.cs (1)
91
public static
ImmutableSegmentedDictionary
<K, ImmutableArray<V>> ToImmutableSegmentedDictionaryAndFree<K, V>(this IReadOnlyDictionary<K, ArrayBuilder<V>> builder)
src\Dependencies\Collections\ImmutableSegmentedDictionary.cs (21)
17
public static
ImmutableSegmentedDictionary
<TKey, TValue> Create<TKey, TValue>()
19
=>
ImmutableSegmentedDictionary
<TKey, TValue>.Empty;
21
public static
ImmutableSegmentedDictionary
<TKey, TValue> Create<TKey, TValue>(IEqualityComparer<TKey>? keyComparer)
23
=>
ImmutableSegmentedDictionary
<TKey, TValue>.Empty.WithComparer(keyComparer);
25
public static
ImmutableSegmentedDictionary
<TKey, TValue>.Builder CreateBuilder<TKey, TValue>()
29
public static
ImmutableSegmentedDictionary
<TKey, TValue>.Builder CreateBuilder<TKey, TValue>(IEqualityComparer<TKey>? keyComparer)
33
public static
ImmutableSegmentedDictionary
<TKey, TValue> CreateRange<TKey, TValue>(IEnumerable<KeyValuePair<TKey, TValue>> items)
35
=>
ImmutableSegmentedDictionary
<TKey, TValue>.Empty.AddRange(items);
37
public static
ImmutableSegmentedDictionary
<TKey, TValue> CreateRange<TKey, TValue>(IEqualityComparer<TKey>? keyComparer, IEnumerable<KeyValuePair<TKey, TValue>> items)
39
=>
ImmutableSegmentedDictionary
<TKey, TValue>.Empty.WithComparer(keyComparer).AddRange(items);
41
public static
ImmutableSegmentedDictionary
<TKey, TValue> ToImmutableSegmentedDictionary<TKey, TValue>(this IEnumerable<KeyValuePair<TKey, TValue>> items)
45
public static
ImmutableSegmentedDictionary
<TKey, TValue> ToImmutableSegmentedDictionary<TKey, TValue>(this
ImmutableSegmentedDictionary
<TKey, TValue>.Builder builder)
54
public static
ImmutableSegmentedDictionary
<TKey, TValue> ToImmutableSegmentedDictionary<TKey, TValue>(this IEnumerable<KeyValuePair<TKey, TValue>> items, IEqualityComparer<TKey>? keyComparer)
60
if (items is
ImmutableSegmentedDictionary
<TKey, TValue> existingDictionary)
63
return
ImmutableSegmentedDictionary
<TKey, TValue>.Empty.WithComparer(keyComparer).AddRange(items);
66
public static
ImmutableSegmentedDictionary
<TKey, TValue> ToImmutableSegmentedDictionary<TSource, TKey, TValue>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TValue> elementSelector)
70
public static
ImmutableSegmentedDictionary
<TKey, TValue> ToImmutableSegmentedDictionary<TSource, TKey, TValue>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TValue> elementSelector, IEqualityComparer<TKey>? keyComparer)
80
return
ImmutableSegmentedDictionary
<TKey, TValue>.Empty.WithComparer(keyComparer)
84
public static
ImmutableSegmentedDictionary
<TKey, TSource> ToImmutableSegmentedDictionary<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
88
public static
ImmutableSegmentedDictionary
<TKey, TSource> ToImmutableSegmentedDictionary<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey>? keyComparer)
src\Dependencies\Collections\ImmutableSegmentedDictionary`2.cs (35)
17
/// <para>There are different scenarios best for <see cref="
ImmutableSegmentedDictionary
{TKey, TValue}"/> and others
20
/// <para>In general, <see cref="
ImmutableSegmentedDictionary
{TKey, TValue}"/> is applicable in scenarios most like
26
/// <see cref="
ImmutableSegmentedDictionary
{TKey, TValue}"/>:</para>
31
/// <description><see cref="
ImmutableSegmentedDictionary
{TKey, TValue}"/> Complexity</description>
70
internal readonly partial struct ImmutableSegmentedDictionary<TKey, TValue> : IImmutableDictionary<TKey, TValue>, IDictionary<TKey, TValue>, IReadOnlyDictionary<TKey, TValue>, IDictionary, IEquatable<
ImmutableSegmentedDictionary
<TKey, TValue>>
73
public static readonly
ImmutableSegmentedDictionary
<TKey, TValue> Empty = new(new SegmentedDictionary<TKey, TValue>());
132
public static bool operator ==(
ImmutableSegmentedDictionary
<TKey, TValue> left,
ImmutableSegmentedDictionary
<TKey, TValue> right)
135
public static bool operator !=(
ImmutableSegmentedDictionary
<TKey, TValue> left,
ImmutableSegmentedDictionary
<TKey, TValue> right)
138
public static bool operator ==(
ImmutableSegmentedDictionary
<TKey, TValue>? left,
ImmutableSegmentedDictionary
<TKey, TValue>? right)
141
public static bool operator !=(
ImmutableSegmentedDictionary
<TKey, TValue>? left,
ImmutableSegmentedDictionary
<TKey, TValue>? right)
144
public
ImmutableSegmentedDictionary
<TKey, TValue> Add(TKey key, TValue value)
146
var
self = this;
155
public
ImmutableSegmentedDictionary
<TKey, TValue> AddRange(IEnumerable<KeyValuePair<TKey, TValue>> pairs)
157
var
self = this;
160
if (self.IsEmpty && TryCastToImmutableSegmentedDictionary(pairs, out
var
other) && self.KeyComparer == other.KeyComparer)
170
public
ImmutableSegmentedDictionary
<TKey, TValue> Clear()
172
var
self = this;
196
public
ImmutableSegmentedDictionary
<TKey, TValue> Remove(TKey key)
198
var
self = this;
207
public
ImmutableSegmentedDictionary
<TKey, TValue> RemoveRange(IEnumerable<TKey> keys)
217
public
ImmutableSegmentedDictionary
<TKey, TValue> SetItem(TKey key, TValue value)
219
var
self = this;
230
public
ImmutableSegmentedDictionary
<TKey, TValue> SetItems(IEnumerable<KeyValuePair<TKey, TValue>> items)
246
var
self = this;
265
public
ImmutableSegmentedDictionary
<TKey, TValue> WithComparer(IEqualityComparer<TKey>? keyComparer)
269
var
self = this;
303
return obj is
ImmutableSegmentedDictionary
<TKey, TValue> other
307
public bool Equals(
ImmutableSegmentedDictionary
<TKey, TValue> other)
372
private static bool TryCastToImmutableSegmentedDictionary(IEnumerable<KeyValuePair<TKey, TValue>> pairs, out
ImmutableSegmentedDictionary
<TKey, TValue> other)
374
if (pairs is
ImmutableSegmentedDictionary
<TKey, TValue> dictionary)
380
if (pairs is
ImmutableSegmentedDictionary
<TKey, TValue>.Builder builder)
src\Dependencies\Collections\ImmutableSegmentedDictionary`2+Builder.cs (2)
22
internal Builder(
ImmutableSegmentedDictionary
<TKey, TValue> dictionary)
120
public
ImmutableSegmentedDictionary
<TKey, TValue> ToImmutable()
src\Dependencies\Collections\ImmutableSegmentedDictionary`2+Builder+KeyCollection.cs (3)
18
private readonly
ImmutableSegmentedDictionary
<TKey, TValue>.Builder _dictionary;
20
internal KeyCollection(
ImmutableSegmentedDictionary
<TKey, TValue>.Builder dictionary)
46
public
ImmutableSegmentedDictionary
<TKey, TValue>.KeyCollection.Enumerator GetEnumerator()
src\Dependencies\Collections\ImmutableSegmentedDictionary`2+Builder+PrivateMarshal.cs (1)
16
/// <inheritdoc cref="SegmentedCollectionsMarshal.GetValueRefOrNullRef{TKey, TValue}(
ImmutableSegmentedDictionary
{TKey, TValue}.Builder, TKey)"/>
src\Dependencies\Collections\ImmutableSegmentedDictionary`2+Builder+ValueCollection.cs (3)
18
private readonly
ImmutableSegmentedDictionary
<TKey, TValue>.Builder _dictionary;
20
internal ValueCollection(
ImmutableSegmentedDictionary
<TKey, TValue>.Builder dictionary)
46
public
ImmutableSegmentedDictionary
<TKey, TValue>.ValueCollection.Enumerator GetEnumerator()
src\Dependencies\Collections\ImmutableSegmentedDictionary`2+Enumerator.cs (1)
38
/// <see cref="
ImmutableSegmentedDictionary
{TKey, TValue}"/>.
src\Dependencies\Collections\ImmutableSegmentedDictionary`2+KeyCollection.cs (2)
15
private readonly
ImmutableSegmentedDictionary
<TKey, TValue> _dictionary;
17
internal KeyCollection(
ImmutableSegmentedDictionary
<TKey, TValue> dictionary)
src\Dependencies\Collections\ImmutableSegmentedDictionary`2+KeyCollection+Enumerator.cs (2)
16
private
ImmutableSegmentedDictionary
<TKey, TValue>.Enumerator _enumerator;
18
internal Enumerator(
ImmutableSegmentedDictionary
<TKey, TValue>.Enumerator enumerator)
src\Dependencies\Collections\ImmutableSegmentedDictionary`2+PrivateMarshal.cs (14)
18
internal static
ImmutableSegmentedDictionary
<TKey, TValue> VolatileRead(in
ImmutableSegmentedDictionary
<TKey, TValue> location)
27
internal static
ImmutableSegmentedDictionary
<TKey, TValue> InterlockedExchange(ref
ImmutableSegmentedDictionary
<TKey, TValue> location,
ImmutableSegmentedDictionary
<TKey, TValue> value)
36
internal static
ImmutableSegmentedDictionary
<TKey, TValue> InterlockedCompareExchange(ref
ImmutableSegmentedDictionary
<TKey, TValue> location,
ImmutableSegmentedDictionary
<TKey, TValue> value,
ImmutableSegmentedDictionary
<TKey, TValue> comparand)
45
/// <inheritdoc cref="SegmentedCollectionsMarshal.GetValueRefOrNullRef{TKey, TValue}(
ImmutableSegmentedDictionary
{TKey, TValue}, TKey)"/>
46
public static ref readonly TValue FindValue(
ImmutableSegmentedDictionary
<TKey, TValue> dictionary, TKey key)
50
internal static
ImmutableSegmentedDictionary
<TKey, TValue> AsImmutableSegmentedDictionary(SegmentedDictionary<TKey, TValue>? dictionary)
53
/// <inheritdoc cref="SegmentedCollectionsMarshal.AsSegmentedDictionary{TKey, TValue}(
ImmutableSegmentedDictionary
{TKey, TValue})"/>
54
internal static SegmentedDictionary<TKey, TValue>? AsSegmentedDictionary(
ImmutableSegmentedDictionary
<TKey, TValue> dictionary)
src\Dependencies\Collections\ImmutableSegmentedDictionary`2+ValueBuilder.cs (4)
19
private
ImmutableSegmentedDictionary
<TKey, TValue> _dictionary;
27
internal ValueBuilder(
ImmutableSegmentedDictionary
<TKey, TValue> dictionary)
98
var
originalDictionary = RoslynImmutableInterlocked.InterlockedExchange(ref _dictionary, default);
227
public
ImmutableSegmentedDictionary
<TKey, TValue> ToImmutable()
src\Dependencies\Collections\ImmutableSegmentedDictionary`2+ValueCollection.cs (2)
15
private readonly
ImmutableSegmentedDictionary
<TKey, TValue> _dictionary;
17
internal ValueCollection(
ImmutableSegmentedDictionary
<TKey, TValue> dictionary)
src\Dependencies\Collections\ImmutableSegmentedDictionary`2+ValueCollection+Enumerator.cs (2)
16
private
ImmutableSegmentedDictionary
<TKey, TValue>.Enumerator _enumerator;
18
internal Enumerator(
ImmutableSegmentedDictionary
<TKey, TValue>.Enumerator enumerator)
src\Dependencies\Collections\RoslynImmutableInterlocked.cs (62)
273
public static bool Update<TKey, TValue>(ref
ImmutableSegmentedDictionary
<TKey, TValue> location, Func<
ImmutableSegmentedDictionary
<TKey, TValue>,
ImmutableSegmentedDictionary
<TKey, TValue>> transformer)
279
var
oldValue =
ImmutableSegmentedDictionary
<TKey, TValue>.PrivateMarshal.VolatileRead(in location);
282
var
newValue = transformer(oldValue);
289
var
interlockedResult = InterlockedCompareExchange(ref location, newValue, oldValue);
316
public static bool Update<TKey, TValue, TArg>(ref
ImmutableSegmentedDictionary
<TKey, TValue> location, Func<
ImmutableSegmentedDictionary
<TKey, TValue>, TArg,
ImmutableSegmentedDictionary
<TKey, TValue>> transformer, TArg transformerArgument)
322
var
oldValue =
ImmutableSegmentedDictionary
<TKey, TValue>.PrivateMarshal.VolatileRead(in location);
325
var
newValue = transformer(oldValue, transformerArgument);
332
var
interlockedResult = InterlockedCompareExchange(ref location, newValue, oldValue);
349
public static
ImmutableSegmentedDictionary
<TKey, TValue> InterlockedExchange<TKey, TValue>(ref
ImmutableSegmentedDictionary
<TKey, TValue> location,
ImmutableSegmentedDictionary
<TKey, TValue> value)
352
return
ImmutableSegmentedDictionary
<TKey, TValue>.PrivateMarshal.InterlockedExchange(ref location, value);
365
public static
ImmutableSegmentedDictionary
<TKey, TValue> InterlockedCompareExchange<TKey, TValue>(ref
ImmutableSegmentedDictionary
<TKey, TValue> location,
ImmutableSegmentedDictionary
<TKey, TValue> value,
ImmutableSegmentedDictionary
<TKey, TValue> comparand)
368
return
ImmutableSegmentedDictionary
<TKey, TValue>.PrivateMarshal.InterlockedCompareExchange(ref location, value, comparand);
381
public static bool InterlockedInitialize<TKey, TValue>(ref
ImmutableSegmentedDictionary
<TKey, TValue> location,
ImmutableSegmentedDictionary
<TKey, TValue> value)
384
return InterlockedCompareExchange(ref location, value, default(
ImmutableSegmentedDictionary
<TKey, TValue>)).IsDefault;
388
public static TValue GetOrAdd<TKey, TValue, TArg>(ref
ImmutableSegmentedDictionary
<TKey, TValue> location, TKey key, Func<TKey, TArg, TValue> valueFactory, TArg factoryArgument)
394
var
map =
ImmutableSegmentedDictionary
<TKey, TValue>.PrivateMarshal.VolatileRead(in location);
408
public static TValue GetOrAdd<TKey, TValue>(ref
ImmutableSegmentedDictionary
<TKey, TValue> location, TKey key, Func<TKey, TValue> valueFactory)
414
var
map =
ImmutableSegmentedDictionary
<TKey, TValue>.PrivateMarshal.VolatileRead(in location);
428
public static TValue GetOrAdd<TKey, TValue>(ref
ImmutableSegmentedDictionary
<TKey, TValue> location, TKey key, TValue value)
431
var
priorCollection =
ImmutableSegmentedDictionary
<TKey, TValue>.PrivateMarshal.VolatileRead(in location);
442
var
updatedCollection = priorCollection.Add(key, value);
443
var
interlockedResult = InterlockedCompareExchange(ref location, updatedCollection, priorCollection);
456
public static TValue AddOrUpdate<TKey, TValue>(ref
ImmutableSegmentedDictionary
<TKey, TValue> location, TKey key, Func<TKey, TValue> addValueFactory, Func<TKey, TValue, TValue> updateValueFactory)
465
var
priorCollection =
ImmutableSegmentedDictionary
<TKey, TValue>.PrivateMarshal.VolatileRead(in location);
480
var
updatedCollection = priorCollection.SetItem(key, newValue);
481
var
interlockedResult = InterlockedCompareExchange(ref location, updatedCollection, priorCollection);
494
public static TValue AddOrUpdate<TKey, TValue>(ref
ImmutableSegmentedDictionary
<TKey, TValue> location, TKey key, TValue addValue, Func<TKey, TValue, TValue> updateValueFactory)
501
var
priorCollection =
ImmutableSegmentedDictionary
<TKey, TValue>.PrivateMarshal.VolatileRead(in location);
516
var
updatedCollection = priorCollection.SetItem(key, newValue);
517
var
interlockedResult = InterlockedCompareExchange(ref location, updatedCollection, priorCollection);
530
public static bool TryAdd<TKey, TValue>(ref
ImmutableSegmentedDictionary
<TKey, TValue> location, TKey key, TValue value)
533
var
priorCollection =
ImmutableSegmentedDictionary
<TKey, TValue>.PrivateMarshal.VolatileRead(in location);
544
var
updatedCollection = priorCollection.Add(key, value);
545
var
interlockedResult = InterlockedCompareExchange(ref location, updatedCollection, priorCollection);
556
public static bool TryUpdate<TKey, TValue>(ref
ImmutableSegmentedDictionary
<TKey, TValue> location, TKey key, TValue newValue, TValue comparisonValue)
560
var
priorCollection =
ImmutableSegmentedDictionary
<TKey, TValue>.PrivateMarshal.VolatileRead(in location);
572
var
updatedCollection = priorCollection.SetItem(key, newValue);
573
var
interlockedResult = InterlockedCompareExchange(ref location, updatedCollection, priorCollection);
584
public static bool TryRemove<TKey, TValue>(ref
ImmutableSegmentedDictionary
<TKey, TValue> location, TKey key, [MaybeNullWhen(false)] out TValue value)
587
var
priorCollection =
ImmutableSegmentedDictionary
<TKey, TValue>.PrivateMarshal.VolatileRead(in location);
598
var
updatedCollection = priorCollection.Remove(key);
599
var
interlockedResult = InterlockedCompareExchange(ref location, updatedCollection, priorCollection);
src\Dependencies\Collections\SegmentedCollectionsMarshal.cs (24)
62
/// Gets either a read-only ref to a <typeparamref name="TValue"/> in the <see cref="
ImmutableSegmentedDictionary
{TKey, TValue}"/>
73
public static ref readonly TValue GetValueRefOrNullRef<TKey, TValue>(
ImmutableSegmentedDictionary
<TKey, TValue> dictionary, TKey key)
75
=> ref
ImmutableSegmentedDictionary
<TKey, TValue>.PrivateMarshal.FindValue(dictionary, key);
78
/// Gets either a ref to a <typeparamref name="TValue"/> in the <see cref="
ImmutableSegmentedDictionary
{TKey, TValue}.Builder"/>
86
/// Items should not be added or removed from the <see cref="
ImmutableSegmentedDictionary
{TKey, TValue}.Builder"/>
91
public static ref TValue GetValueRefOrNullRef<TKey, TValue>(
ImmutableSegmentedDictionary
<TKey, TValue>.Builder dictionary, TKey key)
93
=> ref
ImmutableSegmentedDictionary
<TKey, TValue>.Builder.PrivateMarshal.FindValue(dictionary, key);
180
/// Gets an <see cref="
ImmutableSegmentedDictionary
{TKey, TValue}"/> value wrapping the input <see cref="SegmentedDictionary{TKey, TValue}"/>.
184
/// <param name="dictionary">The input segmented dictionary to wrap in the returned <see cref="
ImmutableSegmentedDictionary
{TKey, TValue}"/> value.</param>
185
/// <returns>An <see cref="
ImmutableSegmentedDictionary
{TKey, TValue}"/> value wrapping <paramref name="dictionary"/>.</returns>
189
/// dictionary, and that it won't be modified once the returned <see cref="
ImmutableSegmentedDictionary
{TKey, TValue}"/>
191
/// of a given <see cref="
ImmutableSegmentedDictionary
{TKey, TValue}"/> values to change after its creation.
194
/// If <paramref name="dictionary"/> is <see langword="null"/>, the returned <see cref="
ImmutableSegmentedDictionary
{TKey, TValue}"/>
195
/// value will be uninitialized (i.e. its <see cref="
ImmutableSegmentedDictionary
{TKey, TValue}.IsDefault"/>
199
public static
ImmutableSegmentedDictionary
<TKey, TValue> AsImmutableSegmentedDictionary<TKey, TValue>(SegmentedDictionary<TKey, TValue>? dictionary)
201
=>
ImmutableSegmentedDictionary
<TKey, TValue>.PrivateMarshal.AsImmutableSegmentedDictionary(dictionary);
204
/// Gets the underlying <see cref="SegmentedDictionary{TKey, TValue}"/> for an input <see cref="
ImmutableSegmentedDictionary
{TKey, TValue}"/> value.
206
/// <typeparam name="TKey">The type of keys in the input <see cref="
ImmutableSegmentedDictionary
{TKey, TValue}"/> value.</typeparam>
207
/// <typeparam name="TValue">The type of values in the input <see cref="
ImmutableSegmentedDictionary
{TKey, TValue}"/> value.</typeparam>
208
/// <param name="dictionary">The input <see cref="
ImmutableSegmentedDictionary
{TKey, TValue}"/> value to get the underlying <see cref="SegmentedDictionary{TKey, TValue}"/> from.</param>
214
/// don't expect the contents of the <see cref="
ImmutableSegmentedDictionary
{TKey, TValue}"/> value to change.
217
/// If <paramref name="dictionary"/> is uninitialized (i.e. its <see cref="
ImmutableSegmentedDictionary
{TKey, TValue}.IsDefault"/>
221
public static SegmentedDictionary<TKey, TValue>? AsSegmentedDictionary<TKey, TValue>(
ImmutableSegmentedDictionary
<TKey, TValue> dictionary)
223
=>
ImmutableSegmentedDictionary
<TKey, TValue>.PrivateMarshal.AsSegmentedDictionary(dictionary);