Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ Add()

HashBucket System.Collections.Immutable.ImmutableDictionary< TKey, TValue >.HashBucket.Add ( TKey key,
TValue value,
IEqualityComparer< KeyValuePair< TKey, TValue > > keyOnlyComparer,
IEqualityComparer< TValue > valueComparer,
KeyCollisionBehavior behavior,
out OperationResult result )
inlinepackage

Definition at line 747 of file ImmutableDictionary.cs.

748 {
750 if (IsEmpty)
751 {
752 result = OperationResult.SizeChanged;
753 return new HashBucket(keyValuePair);
754 }
756 {
757 switch (behavior)
758 {
759 case KeyCollisionBehavior.SetValue:
760 result = OperationResult.AppliedWithoutSizeChange;
762 case KeyCollisionBehavior.Skip:
763 result = OperationResult.NoChangeRequired;
764 return this;
765 case KeyCollisionBehavior.ThrowIfValueDifferent:
766 if (!valueComparer.Equals(_firstValue.Value, value))
767 {
769 }
770 result = OperationResult.NoChangeRequired;
771 return this;
772 case KeyCollisionBehavior.ThrowAlways:
774 default:
775 throw new InvalidOperationException();
776 }
777 }
779 if (num < 0)
780 {
781 result = OperationResult.SizeChanged;
783 }
784 switch (behavior)
785 {
786 case KeyCollisionBehavior.SetValue:
787 result = OperationResult.AppliedWithoutSizeChange;
788 return new HashBucket(_firstValue, _additionalElements.ReplaceAt(num, keyValuePair));
789 case KeyCollisionBehavior.Skip:
790 result = OperationResult.NoChangeRequired;
791 return this;
792 case KeyCollisionBehavior.ThrowIfValueDifferent:
793 if (!valueComparer.Equals(_additionalElements.ItemRef(num).Value, value))
794 {
796 }
797 result = OperationResult.NoChangeRequired;
798 return this;
799 case KeyCollisionBehavior.ThrowAlways:
801 default:
802 throw new InvalidOperationException();
803 }
804 }
KeyCollisionBehavior
int IndexOf(T item, int index, int count, IEqualityComparer< T >? equalityComparer)
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string DuplicateKey
Definition SR.cs:28
Definition SR.cs:7
readonly ImmutableList< KeyValuePair< TKey, TValue > >.Node _additionalElements
HashBucket(KeyValuePair< TKey, TValue > firstElement, ImmutableList< KeyValuePair< TKey, TValue > >.Node additionalElements=null)

References System.Collections.Immutable.ImmutableDictionary< TKey, TValue >.HashBucket.HashBucket(), System.Collections.Immutable.ImmutableDictionary< TKey, TValue >.HashBucket._additionalElements, System.Collections.Immutable.ImmutableDictionary< TKey, TValue >.HashBucket._firstValue, System.Collections.Immutable.ImmutableList< T >.Add(), System.SR.DuplicateKey, System.SR.Format(), System.Collections.Immutable.ImmutableList< T >.IndexOf(), System.Collections.Immutable.ImmutableDictionary< TKey, TValue >.HashBucket.IsEmpty, System.Collections.Immutable.ImmutableList< T >.ItemRef(), System.key, and System.value.