Exemplo n.º 1
0
        public override int GetHashCode()
        {
            // We are fortunate enough to have 3 interesting points here. If you xor an even number of snapshot point hashcodes
            // together, the snapshot component gets cancelled out.

            // However, the common case is that ActivePoint and InsertionPoint are exactly equal, so we need to do something to change that.
            // Invert the bytes in InsertionPoint.GetHashCode().
            var insertionHash = (uint)InsertionPoint.GetHashCode();

            insertionHash = (((0x0000FFFF & insertionHash) << 16) | ((0xFFFF0000 & insertionHash) >> 16));

            int pointHashes = AnchorPoint.GetHashCode() ^ ActivePoint.GetHashCode() ^ (int)insertionHash;

            // InsertionPointAffinity.GetHashCode() returns either 0 or 1 which can get stomped on by the rest of the hash codes.
            // Generate more interesting hash code values below:
            int affinityHash = InsertionPointAffinity == PositionAffinity.Predecessor
                ? affinityHash = 04122013
                : affinityHash = 10172014;

            return(pointHashes ^ affinityHash);
        }