Example #1
0
 /// <summary>
 /// Determines whether the specified key is contained.
 /// </summary>
 /// <param name="key">The key.</param>
 /// <returns>
 ///   <c>true</c> if the specified key is contained; otherwise, <c>false</c>.
 /// </returns>
 public bool ContainsKey(TKey key)
 {
     return(_wrapped.ContainsKey
            (
                _keyComparer.GetHashCode(key),
                input =>
     {
         TKey foundKey;
         if (PrivateTryGetValue(input, out foundKey))
         {
             return _keyComparer.Equals(foundKey, key);
         }
         return false;
     }
            ));
 }
Example #2
0
        bool ICollection <KeyValuePair <TKey, TValue> > .Contains(KeyValuePair <TKey, TValue> item)
        {
            // No risk of dead needles here
            Predicate <WeakNeedle <TKey> > check = input =>
            {
                TKey foundKey;
                if (PrivateTryGetValue(input, out foundKey))
                {
                    return(_keyComparer.Equals(foundKey, item.Key));
                }
                return(false);
            };

            return(_wrapped.ContainsKey
                   (
                       _keyComparer.GetHashCode(item.Key),
                       check,
                       input => EqualityComparer <TValue> .Default.Equals(input, item.Value)
                   ));
        }