示例#1
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)));
 }
示例#2
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);
 }