コード例 #1
0
        public static int GetHashCode <T>(T[] a)
        {
            if (a == null)
            {
                return(0);
            }

            int  result      = 1;
            bool isValueType = typeof(T).GetTypeInfo().IsValueType;

            foreach (var item in a)
            {
                result = 31 * result + (item == null ? 0 :
                                        // LUCENENET specific: if this is a reference type, pass to
                                        // Collections.GetHashCode() in case we have an array of collections
                                        (isValueType ? item.GetHashCode() : Collections.GetHashCode(item)));
            }

            return(result);
        }
コード例 #2
0
 /// <summary>
 /// Returns the hash code value for this list.
 /// <para/>
 /// The hash code determination takes into consideration any values in
 /// this collection and values of any nested collections, but does not
 /// take into consideration the data type. Therefore, the hash codes will
 /// be exactly the same for this <see cref="EquatableSet{T}"/> and another
 /// <see cref="ISet{T}"/> with the same values (in any order).
 /// </summary>
 /// <returns>the hash code value for this list</returns>
 public override int GetHashCode()
 {
     return(Collections.GetHashCode(this));
 }