5 instantiations of Node
System.Collections.Immutable (5)
System\Collections\Immutable\ImmutableSortedDictionary_2.Node.cs (5)
22
internal static readonly Node EmptyNode = new
Node
();
605
return new
Node
(item.Key, item.Value, left, right, true);
628
return new
Node
(key, value, this, this);
661
result = new
Node
(key, value, _left!, _right!);
760
return new
Node
(_key, _value, left ?? _left, right ?? _right);
88 references to Node
System.Collections.Immutable (88)
System\Collections\Immutable\ImmutableSortedDictionary_2.Builder.cs (6)
34
private
Node
_root =
Node
.EmptyNode;
145
private
Node
Root
306
ImmutableSortedDictionary<TKey, TValue>.
Node
newRoot =
Node
.EmptyNode;
493
this.Root = ImmutableSortedDictionary<TKey, TValue>.
Node
.EmptyNode;
System\Collections\Immutable\ImmutableSortedDictionary_2.cs (15)
29
private readonly
Node
_root;
55
_root =
Node
.EmptyNode;
65
private ImmutableSortedDictionary(
Node
root, int count, IComparer<TKey> keyComparer, IEqualityComparer<TValue> valueComparer)
248
ImmutableSortedDictionary<TKey, TValue>.
Node
result = _root.Add(key, value, _keyComparer, _valueComparer, out _);
259
ImmutableSortedDictionary<TKey, TValue>.
Node
result = _root.SetItem(key, value, _keyComparer, _valueComparer, out replacedExistingValue, out _);
291
ImmutableSortedDictionary<TKey, TValue>.
Node
result = _root.Remove(value, _keyComparer, out _);
302
ImmutableSortedDictionary<TKey, TValue>.
Node
result = _root;
307
ImmutableSortedDictionary<TKey, TValue>.
Node
newResult = result.Remove(key, _keyComparer, out mutated);
343
var result = new ImmutableSortedDictionary<TKey, TValue>(
Node
.EmptyNode, 0, keyComparer, valueComparer);
739
private static ImmutableSortedDictionary<TKey, TValue> Wrap(
Node
root, int count, IComparer<TKey> keyComparer, IEqualityComparer<TValue> valueComparer)
788
ImmutableSortedDictionary<TKey, TValue>.
Node
result = _root;
794
ImmutableSortedDictionary<TKey, TValue>.
Node
newResult = overwriteOnCollision
816
private ImmutableSortedDictionary<TKey, TValue> Wrap(
Node
root, int adjustedCountIfDifferentRoot)
881
Node
root =
Node
.NodeTreeFromSortedDictionary(dictionary);
System\Collections\Immutable\ImmutableSortedDictionary_2.Enumerator.cs (15)
42
private
Node
_root;
47
private SecurePooledObject<Stack<RefAsValueType<
Node
>>>? _stack;
52
private
Node
? _current;
64
internal Enumerator(
Node
root, Builder? builder = null)
76
if (!SecureObjectPool<Stack<RefAsValueType<
Node
>>, Enumerator>.TryTake(this, out _stack))
78
_stack = SecureObjectPool<Stack<RefAsValueType<
Node
>>, Enumerator>.PrepNew(this, new Stack<RefAsValueType<
Node
>>(root.Height));
123
if (_stack != null && _stack.TryUse(ref this, out Stack<RefAsValueType<
Node
>>? stack))
126
SecureObjectPool<Stack<RefAsValueType<
Node
>>, Enumerator>.TryAdd(this, _stack!);
143
Stack<RefAsValueType<ImmutableSortedDictionary<TKey, TValue>.
Node
>> stack = _stack.Use(ref this);
146
Node
n = stack.Pop().Value;
168
Stack<RefAsValueType<ImmutableSortedDictionary<TKey, TValue>.
Node
>> stack = _stack.Use(ref this);
207
private void PushLeft(
Node
node)
211
Stack<RefAsValueType<ImmutableSortedDictionary<TKey, TValue>.
Node
>> stack = _stack.Use(ref this);
214
stack.Push(new RefAsValueType<
Node
>(node));
System\Collections\Immutable\ImmutableSortedDictionary_2.Node.cs (51)
22
internal static readonly
Node
EmptyNode = new Node();
51
private
Node
? _left;
56
private
Node
? _right;
59
/// Initializes a new instance of the <see cref="ImmutableSortedDictionary{TKey, TValue}.
Node
"/> class
69
/// Initializes a new instance of the <see cref="ImmutableSortedDictionary{TKey, TValue}.
Node
"/> class
77
private Node(TKey key, TValue value,
Node
left,
Node
right, bool frozen = false)
116
public
Node
? Left { get { return _left; } }
121
public
Node
? Right { get { return _right; } }
231
internal static
Node
NodeTreeFromSortedDictionary(SortedDictionary<TKey, TValue> dictionary)
247
internal
Node
Add(TKey key, TValue value, IComparer<TKey> keyComparer, IEqualityComparer<TValue> valueComparer, out bool mutated)
265
internal
Node
SetItem(TKey key, TValue value, IComparer<TKey> keyComparer, IEqualityComparer<TValue> valueComparer, out bool replacedExistingValue, out bool mutated)
281
internal
Node
Remove(TKey key, IComparer<TKey> keyComparer, out bool mutated)
298
ImmutableSortedDictionary<TKey, TValue>.
Node
match = this.Search(key, keyComparer);
319
ImmutableSortedDictionary<TKey, TValue>.
Node
match = this.Search(key, keyComparer);
350
ImmutableSortedDictionary<TKey, TValue>.
Node
match = this.Search(equalKey, keyComparer);
419
ImmutableSortedDictionary<TKey, TValue>.
Node
matchingNode = this.Search(pair.Key, keyComparer);
449
private static
Node
RotateLeft(
Node
tree)
459
ImmutableSortedDictionary<TKey, TValue>.
Node
right = tree._right;
468
private static
Node
RotateRight(
Node
tree)
478
ImmutableSortedDictionary<TKey, TValue>.
Node
left = tree._left;
487
private static
Node
DoubleLeft(
Node
tree)
497
Node
rotatedRightChild = tree.Mutate(right: RotateRight(tree._right));
506
private static
Node
DoubleRight(
Node
tree)
516
Node
rotatedLeftChild = tree.Mutate(left: RotateLeft(tree._left));
525
private static int Balance(
Node
tree)
540
private static bool IsRightHeavy(
Node
tree)
550
private static bool IsLeftHeavy(
Node
tree)
562
private static
Node
MakeBalanced(
Node
tree)
589
private static
Node
NodeTreeFromList(IReadOnlyList<KeyValuePair<TKey, TValue>> items, int start, int length)
602
Node
left = NodeTreeFromList(items, start, leftCount);
603
Node
right = NodeTreeFromList(items, start + leftCount + 1, rightCount);
619
private
Node
SetOrAdd(TKey key, TValue value, IComparer<TKey> keyComparer, IEqualityComparer<TValue> valueComparer, bool overwriteExistingValue, out bool replacedExistingValue, out bool mutated)
632
Node
result = this;
636
ImmutableSortedDictionary<TKey, TValue>.
Node
newRight = _right!.SetOrAdd(key, value, keyComparer, valueComparer, overwriteExistingValue, out replacedExistingValue, out mutated);
644
ImmutableSortedDictionary<TKey, TValue>.
Node
newLeft = _left!.SetOrAdd(key, value, keyComparer, valueComparer, overwriteExistingValue, out replacedExistingValue, out mutated);
680
private
Node
RemoveRecursive(TKey key, IComparer<TKey> keyComparer, out bool mutated)
691
Node
result = this;
717
ImmutableSortedDictionary<TKey, TValue>.
Node
successor = _right;
723
ImmutableSortedDictionary<TKey, TValue>.
Node
newRight = _right.Remove(successor._key, keyComparer, out _);
729
ImmutableSortedDictionary<TKey, TValue>.
Node
newLeft = _left.Remove(key, keyComparer, out mutated);
737
ImmutableSortedDictionary<TKey, TValue>.
Node
newRight = _right.Remove(key, keyComparer, out mutated);
755
private
Node
Mutate(
Node
? left = null,
Node
? right = null)
784
private
Node
Search(TKey key, IComparer<TKey> keyComparer)
System\Collections\Immutable\SortedInt32KeyNode.cs (1)
15
/// This is a trimmed down version of <see cref="ImmutableSortedDictionary{TKey, TValue}.
Node
"/>