Beispiel #1
0
 public int GetHashCode(ref KeySegment <E, T> obj, bool objIsWeak)
 {
     return((int)Hasher.Rehash(_elementComparer.GetHashCode(ref obj._elementReference, objIsWeak)) ^ _tail.GetHashCode(ref obj._tail, objIsWeak));
 }
Beispiel #2
0
 /// <summary>
 /// Get a hashcode for given search key.
 /// </summary>
 /// <param name="key">Reference to the key to get a hash value for.</param>
 /// <returns>The hash value as an <see cref="UInt32"/>.</returns>
 /// <remarks>
 /// The hash returned should be properly randomized hash. The standard GetItemHashCode methods are usually not good enough.
 /// A storeable item and a matching search key should return the same hash code.
 /// So the statement <code>ItemEqualsItem(storeableItem, searchKey) ? GetItemHashCode(storeableItem) == GetItemHashCode(searchKey) : true </code> should always be true;
 /// </remarks>
 internal protected override UInt32 GetKeyHashCode(ref ConcurrentDictionaryKey <TKey, TValue> key)
 {
     return(Hasher.Rehash(_Comparer.GetHashCode(key._Key)));
 }
Beispiel #3
0
 public int CalculateHashCode(K obj)
 {
     return((int)Hasher.Rehash(_comparers.GetHashCode(ref obj._values, obj.IsWeak)) ^ _strongValueComparer.GetHashCode(obj._strongValue));
 }
Beispiel #4
0
 /// <summary>
 /// Get a hashcode for given storeable item.
 /// </summary>
 /// <param name="item">Reference to the item to get a hash value for.</param>
 /// <returns>The hash value as an <see cref="UInt32"/>.</returns>
 /// <remarks>
 /// The hash returned should be properly randomized hash. The standard GetItemHashCode methods are usually not good enough.
 /// A storeable item and a matching search key should return the same hash code.
 /// So the statement <code>ItemEqualsItem(storeableItem, searchKey) ? GetItemHashCode(storeableItem) == GetItemHashCode(searchKey) : true </code> should always be true;
 /// </remarks>
 internal protected override UInt32 GetItemHashCode(ref KeyValuePair <TKey, TValue>?item)
 {
     return(item.HasValue ? Hasher.Rehash(_Comparer.GetHashCode(item.Value.Key)) : 0);
 }