Exemplo n.º 1
0
        //=========================================================================================
        /// <summary>
        /// ネイティブ配列からデータハッシュ値を求めて返す
        /// 自分で定義したクラス/構造体は IDataHash インターフェースを継承し、int GetDataHash() を定義する必要があります
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="data"></param>
        /// <returns></returns>
        public static int GetDataHash <T>(this T[] data)
        {
            int hash = 0;

            if (data != null)
            {
                foreach (var d in data)
                {
                    hash = hash * 31;

                    IDataHash dh = d as IDataHash;
                    if (dh != null)
                    {
                        hash += dh.GetDataHash();
                    }
                    else
                    {
                        hash += d.GetDataHash();
                    }
                }
            }

            return(hash);
        }
Exemplo n.º 2
0
 public static int GetDataHash(this IDataHash data)
 {
     return(data.GetDataHash());
 }