GetHashCode() public method

public GetHashCode ( ) : int
return int
コード例 #1
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (ScreenInfo != null ? ScreenInfo.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Color.GetHashCode();
         return(hashCode);
     }
 }
コード例 #2
0
 public override int GetHashCode()
 {
     return(m_color.GetHashCode());
 }
コード例 #3
0
ファイル: GdiRenderer.cs プロジェクト: swax/CodePerspective
        Pen GetPen(Color color, int width, bool dashed)
        {
            int hash = color.GetHashCode() ^ width.GetHashCode() ^ dashed.GetHashCode();

            int debug1 = color.GetHashCode();
            int debug2 = width.GetHashCode();
            int debug3 = dashed.GetHashCode();

            Pen pen;
            if (!PenCache.TryGetValue(hash, out pen))
            {
                pen = new Pen(color, width);

                if (dashed)
                    pen.DashPattern = new float[] { 3, 6 };

                PenCache[hash] = pen;
            }

            return pen;
        }
コード例 #4
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="clr"></param>
        /// <returns></returns>
        public int FindClosestEntry(Color clr)
        {
            // If not sure of consistency with palette, clear the hash table
            if (m_fClearHash)
                m_htbl.Clear();

            // Is this mapping available already?
            int key = clr.GetHashCode();
            if (m_htbl.ContainsKey(key))
                return (int)m_htbl[key];

            // Find the entry, the long way
            int nLowest = 256 * 256 * 3;
            int iLowest = 0;
            int nR = clr.R;
            int nG = clr.G;
            int nB = clr.B;
            for (int iclr = 0; iclr < m_aclr.Length; iclr++) {
                Color clrPal = m_aclr[iclr];
                int dR = clrPal.R - nR;
                int dG = clrPal.G - nG;
                int dB = clrPal.B - nB;
                int nD = dR * dR + dG * dG + dB * dB;
                if (nD < nLowest) {
                    nLowest = nD;
                    iLowest = iclr;
                }
            }

            // Add it to the hash table and return it
            m_htbl.Add(key, iLowest);
            return iLowest;
        }