Last active
October 31, 2020 20:59
-
-
Save joao-r-reis/0b4ef52cd14852e19985b2a3c9c8cafe to your computer and use it in GitHub Desktop.
TryAddInternal.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private bool TryAddInternal(TKey key, TValue value, bool updateIfExists, bool acquireLock, out TValue resultingValue) | |
{ | |
IEqualityComparer<TKey> comparer = m_tables.m_comparer; | |
var hashcode = comparer.GetHashCode(key); | |
var bucketCount = m_tables.m_buckets.Length; | |
var bucketNo = (hashcode & 0x7fffffff) % bucketCount; | |
// removed locking logic for simplicity | |
for (Node node = tables.m_buckets[bucketNo]; node != null; node = node.m_next) | |
{ | |
if (comparer.Equals(node.m_key, key)) | |
{ | |
return false; | |
} | |
} | |
// removed add logic for simplicity | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment