7 instantiations of ImmutableSegmentedDictionary
Microsoft.CodeAnalysis.Collections.Package (7)
Segmented\ImmutableSegmentedDictionary`2.cs (2)
75
public static readonly ImmutableSegmentedDictionary<TKey, TValue> Empty =
new
(new SegmentedDictionary<TKey, TValue>());
285
return new
ImmutableSegmentedDictionary
<TKey, TValue>(new SegmentedDictionary<TKey, TValue>(keyComparer));
Segmented\ImmutableSegmentedDictionary`2+PrivateMarshal.cs (4)
26
return new
ImmutableSegmentedDictionary
<TKey, TValue>(dictionary);
35
return new
ImmutableSegmentedDictionary
<TKey, TValue>(dictionary);
44
return new
ImmutableSegmentedDictionary
<TKey, TValue>(dictionary);
53
=> dictionary is not null ? new
ImmutableSegmentedDictionary
<TKey, TValue>(dictionary) : default;
Segmented\ImmutableSegmentedDictionary`2+ValueBuilder.cs (1)
231
_dictionary = new
ImmutableSegmentedDictionary
<TKey, TValue>(ReadOnlyDictionary);
178 references to ImmutableSegmentedDictionary
Microsoft.CodeAnalysis.Collections.Package (178)
RoslynImmutableInterlocked.cs (62)
276
public static bool Update<TKey, TValue>(ref
ImmutableSegmentedDictionary
<TKey, TValue> location, Func<
ImmutableSegmentedDictionary
<TKey, TValue>,
ImmutableSegmentedDictionary
<TKey, TValue>> transformer)
282
var
oldValue =
ImmutableSegmentedDictionary
<TKey, TValue>.PrivateMarshal.VolatileRead(in location);
285
var
newValue = transformer(oldValue);
292
var
interlockedResult = InterlockedCompareExchange(ref location, newValue, oldValue);
319
public static bool Update<TKey, TValue, TArg>(ref
ImmutableSegmentedDictionary
<TKey, TValue> location, Func<
ImmutableSegmentedDictionary
<TKey, TValue>, TArg,
ImmutableSegmentedDictionary
<TKey, TValue>> transformer, TArg transformerArgument)
325
var
oldValue =
ImmutableSegmentedDictionary
<TKey, TValue>.PrivateMarshal.VolatileRead(in location);
328
var
newValue = transformer(oldValue, transformerArgument);
335
var
interlockedResult = InterlockedCompareExchange(ref location, newValue, oldValue);
352
public static
ImmutableSegmentedDictionary
<TKey, TValue> InterlockedExchange<TKey, TValue>(ref
ImmutableSegmentedDictionary
<TKey, TValue> location,
ImmutableSegmentedDictionary
<TKey, TValue> value)
355
return
ImmutableSegmentedDictionary
<TKey, TValue>.PrivateMarshal.InterlockedExchange(ref location, value);
368
public static
ImmutableSegmentedDictionary
<TKey, TValue> InterlockedCompareExchange<TKey, TValue>(ref
ImmutableSegmentedDictionary
<TKey, TValue> location,
ImmutableSegmentedDictionary
<TKey, TValue> value,
ImmutableSegmentedDictionary
<TKey, TValue> comparand)
371
return
ImmutableSegmentedDictionary
<TKey, TValue>.PrivateMarshal.InterlockedCompareExchange(ref location, value, comparand);
384
public static bool InterlockedInitialize<TKey, TValue>(ref
ImmutableSegmentedDictionary
<TKey, TValue> location,
ImmutableSegmentedDictionary
<TKey, TValue> value)
387
return InterlockedCompareExchange(ref location, value, default(
ImmutableSegmentedDictionary
<TKey, TValue>)).IsDefault;
391
public static TValue GetOrAdd<TKey, TValue, TArg>(ref
ImmutableSegmentedDictionary
<TKey, TValue> location, TKey key, Func<TKey, TArg, TValue> valueFactory, TArg factoryArgument)
397
var
map =
ImmutableSegmentedDictionary
<TKey, TValue>.PrivateMarshal.VolatileRead(in location);
411
public static TValue GetOrAdd<TKey, TValue>(ref
ImmutableSegmentedDictionary
<TKey, TValue> location, TKey key, Func<TKey, TValue> valueFactory)
417
var
map =
ImmutableSegmentedDictionary
<TKey, TValue>.PrivateMarshal.VolatileRead(in location);
431
public static TValue GetOrAdd<TKey, TValue>(ref
ImmutableSegmentedDictionary
<TKey, TValue> location, TKey key, TValue value)
434
var
priorCollection =
ImmutableSegmentedDictionary
<TKey, TValue>.PrivateMarshal.VolatileRead(in location);
445
var
updatedCollection = priorCollection.Add(key, value);
446
var
interlockedResult = InterlockedCompareExchange(ref location, updatedCollection, priorCollection);
459
public static TValue AddOrUpdate<TKey, TValue>(ref
ImmutableSegmentedDictionary
<TKey, TValue> location, TKey key, Func<TKey, TValue> addValueFactory, Func<TKey, TValue, TValue> updateValueFactory)
468
var
priorCollection =
ImmutableSegmentedDictionary
<TKey, TValue>.PrivateMarshal.VolatileRead(in location);
483
var
updatedCollection = priorCollection.SetItem(key, newValue);
484
var
interlockedResult = InterlockedCompareExchange(ref location, updatedCollection, priorCollection);
497
public static TValue AddOrUpdate<TKey, TValue>(ref
ImmutableSegmentedDictionary
<TKey, TValue> location, TKey key, TValue addValue, Func<TKey, TValue, TValue> updateValueFactory)
504
var
priorCollection =
ImmutableSegmentedDictionary
<TKey, TValue>.PrivateMarshal.VolatileRead(in location);
519
var
updatedCollection = priorCollection.SetItem(key, newValue);
520
var
interlockedResult = InterlockedCompareExchange(ref location, updatedCollection, priorCollection);
533
public static bool TryAdd<TKey, TValue>(ref
ImmutableSegmentedDictionary
<TKey, TValue> location, TKey key, TValue value)
536
var
priorCollection =
ImmutableSegmentedDictionary
<TKey, TValue>.PrivateMarshal.VolatileRead(in location);
547
var
updatedCollection = priorCollection.Add(key, value);
548
var
interlockedResult = InterlockedCompareExchange(ref location, updatedCollection, priorCollection);
559
public static bool TryUpdate<TKey, TValue>(ref
ImmutableSegmentedDictionary
<TKey, TValue> location, TKey key, TValue newValue, TValue comparisonValue)
563
var
priorCollection =
ImmutableSegmentedDictionary
<TKey, TValue>.PrivateMarshal.VolatileRead(in location);
575
var
updatedCollection = priorCollection.SetItem(key, newValue);
576
var
interlockedResult = InterlockedCompareExchange(ref location, updatedCollection, priorCollection);
587
public static bool TryRemove<TKey, TValue>(ref
ImmutableSegmentedDictionary
<TKey, TValue> location, TKey key, [MaybeNullWhen(false)] out TValue value)
590
var
priorCollection =
ImmutableSegmentedDictionary
<TKey, TValue>.PrivateMarshal.VolatileRead(in location);
601
var
updatedCollection = priorCollection.Remove(key);
602
var
interlockedResult = InterlockedCompareExchange(ref location, updatedCollection, priorCollection);
Segmented\ImmutableSegmentedDictionary.cs (21)
19
public static
ImmutableSegmentedDictionary
<TKey, TValue> Create<TKey, TValue>()
21
=>
ImmutableSegmentedDictionary
<TKey, TValue>.Empty;
23
public static
ImmutableSegmentedDictionary
<TKey, TValue> Create<TKey, TValue>(IEqualityComparer<TKey>? keyComparer)
25
=>
ImmutableSegmentedDictionary
<TKey, TValue>.Empty.WithComparer(keyComparer);
27
public static
ImmutableSegmentedDictionary
<TKey, TValue>.Builder CreateBuilder<TKey, TValue>()
31
public static
ImmutableSegmentedDictionary
<TKey, TValue>.Builder CreateBuilder<TKey, TValue>(IEqualityComparer<TKey>? keyComparer)
35
public static
ImmutableSegmentedDictionary
<TKey, TValue> CreateRange<TKey, TValue>(IEnumerable<KeyValuePair<TKey, TValue>> items)
37
=>
ImmutableSegmentedDictionary
<TKey, TValue>.Empty.AddRange(items);
39
public static
ImmutableSegmentedDictionary
<TKey, TValue> CreateRange<TKey, TValue>(IEqualityComparer<TKey>? keyComparer, IEnumerable<KeyValuePair<TKey, TValue>> items)
41
=>
ImmutableSegmentedDictionary
<TKey, TValue>.Empty.WithComparer(keyComparer).AddRange(items);
43
public static
ImmutableSegmentedDictionary
<TKey, TValue> ToImmutableSegmentedDictionary<TKey, TValue>(this IEnumerable<KeyValuePair<TKey, TValue>> items)
47
public static
ImmutableSegmentedDictionary
<TKey, TValue> ToImmutableSegmentedDictionary<TKey, TValue>(this
ImmutableSegmentedDictionary
<TKey, TValue>.Builder builder)
56
public static
ImmutableSegmentedDictionary
<TKey, TValue> ToImmutableSegmentedDictionary<TKey, TValue>(this IEnumerable<KeyValuePair<TKey, TValue>> items, IEqualityComparer<TKey>? keyComparer)
62
if (items is
ImmutableSegmentedDictionary
<TKey, TValue> existingDictionary)
65
return
ImmutableSegmentedDictionary
<TKey, TValue>.Empty.WithComparer(keyComparer).AddRange(items);
68
public static
ImmutableSegmentedDictionary
<TKey, TValue> ToImmutableSegmentedDictionary<TSource, TKey, TValue>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TValue> elementSelector)
72
public static
ImmutableSegmentedDictionary
<TKey, TValue> ToImmutableSegmentedDictionary<TSource, TKey, TValue>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TValue> elementSelector, IEqualityComparer<TKey>? keyComparer)
82
return
ImmutableSegmentedDictionary
<TKey, TValue>.Empty.WithComparer(keyComparer)
86
public static
ImmutableSegmentedDictionary
<TKey, TSource> ToImmutableSegmentedDictionary<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
90
public static
ImmutableSegmentedDictionary
<TKey, TSource> ToImmutableSegmentedDictionary<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey>? keyComparer)
Segmented\ImmutableSegmentedDictionary`2.cs (35)
19
/// <para>There are different scenarios best for <see cref="
ImmutableSegmentedDictionary
{TKey, TValue}"/> and others
22
/// <para>In general, <see cref="
ImmutableSegmentedDictionary
{TKey, TValue}"/> is applicable in scenarios most like
28
/// <see cref="
ImmutableSegmentedDictionary
{TKey, TValue}"/>:</para>
33
/// <description><see cref="
ImmutableSegmentedDictionary
{TKey, TValue}"/> Complexity</description>
72
internal readonly partial struct ImmutableSegmentedDictionary<TKey, TValue> : IImmutableDictionary<TKey, TValue>, IDictionary<TKey, TValue>, IReadOnlyDictionary<TKey, TValue>, IDictionary, IEquatable<
ImmutableSegmentedDictionary
<TKey, TValue>>
75
public static readonly
ImmutableSegmentedDictionary
<TKey, TValue> Empty = new(new SegmentedDictionary<TKey, TValue>());
134
public static bool operator ==(
ImmutableSegmentedDictionary
<TKey, TValue> left,
ImmutableSegmentedDictionary
<TKey, TValue> right)
137
public static bool operator !=(
ImmutableSegmentedDictionary
<TKey, TValue> left,
ImmutableSegmentedDictionary
<TKey, TValue> right)
140
public static bool operator ==(
ImmutableSegmentedDictionary
<TKey, TValue>? left,
ImmutableSegmentedDictionary
<TKey, TValue>? right)
143
public static bool operator !=(
ImmutableSegmentedDictionary
<TKey, TValue>? left,
ImmutableSegmentedDictionary
<TKey, TValue>? right)
146
public
ImmutableSegmentedDictionary
<TKey, TValue> Add(TKey key, TValue value)
148
var
self = this;
157
public
ImmutableSegmentedDictionary
<TKey, TValue> AddRange(IEnumerable<KeyValuePair<TKey, TValue>> pairs)
159
var
self = this;
162
if (self.IsEmpty && TryCastToImmutableSegmentedDictionary(pairs, out
var
other) && self.KeyComparer == other.KeyComparer)
172
public
ImmutableSegmentedDictionary
<TKey, TValue> Clear()
174
var
self = this;
198
public
ImmutableSegmentedDictionary
<TKey, TValue> Remove(TKey key)
200
var
self = this;
209
public
ImmutableSegmentedDictionary
<TKey, TValue> RemoveRange(IEnumerable<TKey> keys)
219
public
ImmutableSegmentedDictionary
<TKey, TValue> SetItem(TKey key, TValue value)
221
var
self = this;
232
public
ImmutableSegmentedDictionary
<TKey, TValue> SetItems(IEnumerable<KeyValuePair<TKey, TValue>> items)
248
var
self = this;
267
public
ImmutableSegmentedDictionary
<TKey, TValue> WithComparer(IEqualityComparer<TKey>? keyComparer)
271
var
self = this;
305
return obj is
ImmutableSegmentedDictionary
<TKey, TValue> other
309
public bool Equals(
ImmutableSegmentedDictionary
<TKey, TValue> other)
374
private static bool TryCastToImmutableSegmentedDictionary(IEnumerable<KeyValuePair<TKey, TValue>> pairs, out
ImmutableSegmentedDictionary
<TKey, TValue> other)
376
if (pairs is
ImmutableSegmentedDictionary
<TKey, TValue> dictionary)
382
if (pairs is
ImmutableSegmentedDictionary
<TKey, TValue>.Builder builder)
Segmented\ImmutableSegmentedDictionary`2+Builder.cs (2)
24
internal Builder(
ImmutableSegmentedDictionary
<TKey, TValue> dictionary)
122
public
ImmutableSegmentedDictionary
<TKey, TValue> ToImmutable()
Segmented\ImmutableSegmentedDictionary`2+Builder+KeyCollection.cs (3)
20
private readonly
ImmutableSegmentedDictionary
<TKey, TValue>.Builder _dictionary;
22
internal KeyCollection(
ImmutableSegmentedDictionary
<TKey, TValue>.Builder dictionary)
48
public
ImmutableSegmentedDictionary
<TKey, TValue>.KeyCollection.Enumerator GetEnumerator()
Segmented\ImmutableSegmentedDictionary`2+Builder+PrivateMarshal.cs (1)
18
/// <inheritdoc cref="SegmentedCollectionsMarshal.GetValueRefOrNullRef{TKey, TValue}(
ImmutableSegmentedDictionary
{TKey, TValue}.Builder, TKey)"/>
Segmented\ImmutableSegmentedDictionary`2+Builder+ValueCollection.cs (3)
20
private readonly
ImmutableSegmentedDictionary
<TKey, TValue>.Builder _dictionary;
22
internal ValueCollection(
ImmutableSegmentedDictionary
<TKey, TValue>.Builder dictionary)
48
public
ImmutableSegmentedDictionary
<TKey, TValue>.ValueCollection.Enumerator GetEnumerator()
Segmented\ImmutableSegmentedDictionary`2+Enumerator.cs (1)
40
/// <see cref="
ImmutableSegmentedDictionary
{TKey, TValue}"/>.
Segmented\ImmutableSegmentedDictionary`2+KeyCollection.cs (2)
17
private readonly
ImmutableSegmentedDictionary
<TKey, TValue> _dictionary;
19
internal KeyCollection(
ImmutableSegmentedDictionary
<TKey, TValue> dictionary)
Segmented\ImmutableSegmentedDictionary`2+KeyCollection+Enumerator.cs (2)
18
private
ImmutableSegmentedDictionary
<TKey, TValue>.Enumerator _enumerator;
20
internal Enumerator(
ImmutableSegmentedDictionary
<TKey, TValue>.Enumerator enumerator)
Segmented\ImmutableSegmentedDictionary`2+PrivateMarshal.cs (14)
20
internal static
ImmutableSegmentedDictionary
<TKey, TValue> VolatileRead(in
ImmutableSegmentedDictionary
<TKey, TValue> location)
29
internal static
ImmutableSegmentedDictionary
<TKey, TValue> InterlockedExchange(ref
ImmutableSegmentedDictionary
<TKey, TValue> location,
ImmutableSegmentedDictionary
<TKey, TValue> value)
38
internal static
ImmutableSegmentedDictionary
<TKey, TValue> InterlockedCompareExchange(ref
ImmutableSegmentedDictionary
<TKey, TValue> location,
ImmutableSegmentedDictionary
<TKey, TValue> value,
ImmutableSegmentedDictionary
<TKey, TValue> comparand)
47
/// <inheritdoc cref="SegmentedCollectionsMarshal.GetValueRefOrNullRef{TKey, TValue}(
ImmutableSegmentedDictionary
{TKey, TValue}, TKey)"/>
48
public static ref readonly TValue FindValue(
ImmutableSegmentedDictionary
<TKey, TValue> dictionary, TKey key)
52
internal static
ImmutableSegmentedDictionary
<TKey, TValue> AsImmutableSegmentedDictionary(SegmentedDictionary<TKey, TValue>? dictionary)
55
/// <inheritdoc cref="SegmentedCollectionsMarshal.AsSegmentedDictionary{TKey, TValue}(
ImmutableSegmentedDictionary
{TKey, TValue})"/>
56
internal static SegmentedDictionary<TKey, TValue>? AsSegmentedDictionary(
ImmutableSegmentedDictionary
<TKey, TValue> dictionary)
Segmented\ImmutableSegmentedDictionary`2+ValueBuilder.cs (4)
21
private
ImmutableSegmentedDictionary
<TKey, TValue> _dictionary;
29
internal ValueBuilder(
ImmutableSegmentedDictionary
<TKey, TValue> dictionary)
100
var
originalDictionary = RoslynImmutableInterlocked.InterlockedExchange(ref _dictionary, default);
229
public
ImmutableSegmentedDictionary
<TKey, TValue> ToImmutable()
Segmented\ImmutableSegmentedDictionary`2+ValueCollection.cs (2)
17
private readonly
ImmutableSegmentedDictionary
<TKey, TValue> _dictionary;
19
internal ValueCollection(
ImmutableSegmentedDictionary
<TKey, TValue> dictionary)
Segmented\ImmutableSegmentedDictionary`2+ValueCollection+Enumerator.cs (2)
18
private
ImmutableSegmentedDictionary
<TKey, TValue>.Enumerator _enumerator;
20
internal Enumerator(
ImmutableSegmentedDictionary
<TKey, TValue>.Enumerator enumerator)
Segmented\SegmentedCollectionsMarshal.cs (24)
64
/// Gets either a read-only ref to a <typeparamref name="TValue"/> in the <see cref="
ImmutableSegmentedDictionary
{TKey, TValue}"/>
75
public static ref readonly TValue GetValueRefOrNullRef<TKey, TValue>(
ImmutableSegmentedDictionary
<TKey, TValue> dictionary, TKey key)
77
=> ref
ImmutableSegmentedDictionary
<TKey, TValue>.PrivateMarshal.FindValue(dictionary, key);
80
/// Gets either a ref to a <typeparamref name="TValue"/> in the <see cref="
ImmutableSegmentedDictionary
{TKey, TValue}.Builder"/>
88
/// Items should not be added or removed from the <see cref="
ImmutableSegmentedDictionary
{TKey, TValue}.Builder"/>
93
public static ref TValue GetValueRefOrNullRef<TKey, TValue>(
ImmutableSegmentedDictionary
<TKey, TValue>.Builder dictionary, TKey key)
95
=> ref
ImmutableSegmentedDictionary
<TKey, TValue>.Builder.PrivateMarshal.FindValue(dictionary, key);
182
/// Gets an <see cref="
ImmutableSegmentedDictionary
{TKey, TValue}"/> value wrapping the input <see cref="SegmentedDictionary{TKey, TValue}"/>.
186
/// <param name="dictionary">The input segmented dictionary to wrap in the returned <see cref="
ImmutableSegmentedDictionary
{TKey, TValue}"/> value.</param>
187
/// <returns>An <see cref="
ImmutableSegmentedDictionary
{TKey, TValue}"/> value wrapping <paramref name="dictionary"/>.</returns>
191
/// dictionary, and that it won't be modified once the returned <see cref="
ImmutableSegmentedDictionary
{TKey, TValue}"/>
193
/// of a given <see cref="
ImmutableSegmentedDictionary
{TKey, TValue}"/> values to change after its creation.
196
/// If <paramref name="dictionary"/> is <see langword="null"/>, the returned <see cref="
ImmutableSegmentedDictionary
{TKey, TValue}"/>
197
/// value will be uninitialized (i.e. its <see cref="
ImmutableSegmentedDictionary
{TKey, TValue}.IsDefault"/>
201
public static
ImmutableSegmentedDictionary
<TKey, TValue> AsImmutableSegmentedDictionary<TKey, TValue>(SegmentedDictionary<TKey, TValue>? dictionary)
203
=>
ImmutableSegmentedDictionary
<TKey, TValue>.PrivateMarshal.AsImmutableSegmentedDictionary(dictionary);
206
/// Gets the underlying <see cref="SegmentedDictionary{TKey, TValue}"/> for an input <see cref="
ImmutableSegmentedDictionary
{TKey, TValue}"/> value.
208
/// <typeparam name="TKey">The type of keys in the input <see cref="
ImmutableSegmentedDictionary
{TKey, TValue}"/> value.</typeparam>
209
/// <typeparam name="TValue">The type of values in the input <see cref="
ImmutableSegmentedDictionary
{TKey, TValue}"/> value.</typeparam>
210
/// <param name="dictionary">The input <see cref="
ImmutableSegmentedDictionary
{TKey, TValue}"/> value to get the underlying <see cref="SegmentedDictionary{TKey, TValue}"/> from.</param>
216
/// don't expect the contents of the <see cref="
ImmutableSegmentedDictionary
{TKey, TValue}"/> value to change.
219
/// If <paramref name="dictionary"/> is uninitialized (i.e. its <see cref="
ImmutableSegmentedDictionary
{TKey, TValue}.IsDefault"/>
223
public static SegmentedDictionary<TKey, TValue>? AsSegmentedDictionary<TKey, TValue>(
ImmutableSegmentedDictionary
<TKey, TValue> dictionary)
225
=>
ImmutableSegmentedDictionary
<TKey, TValue>.PrivateMarshal.AsSegmentedDictionary(dictionary);