示例#1
0
        public static int GetOrderedCollectionHashCode <T>(this IEnumerable <T> collection)
        {
            if (collection == null)
            {
                return(0);
            }

            int hashCode = 0;

            foreach (T t in collection)
            {
                hashCode = EqualityUtil.CombineHashCodes(hashCode, t.GetHashCode());
            }
            return(hashCode);
        }
示例#2
0
        public static int GetOrderedDictionaryHashCode <TKey, TValue>(this IEnumerable <KeyValuePair <TKey, TValue> > dictionary)
        {
            if (dictionary == null)
            {
                return(0);
            }

            int hashCode = 0;

            foreach (KeyValuePair <TKey, TValue> kvp in dictionary)
            {
                hashCode = EqualityUtil.CombineHashCodes(hashCode, EqualityUtil.CombineHashCodes(kvp.Key.Hash(), kvp.Value.Hash()));
            }
            return(hashCode);
        }
示例#3
0
 public int GetHashCode(KeyValuePair <TKey, TValue> obj)
 {
     return(EqualityUtil.CombineHashCodes(obj.Key.Hash(), obj.Value.Hash()));
 }