Microsoft.Scripting.Math.BigInteger.GetHashCode C# (CSharp) Méthode

GetHashCode() public méthode

public GetHashCode ( ) : int
Résultat int
    public override int GetHashCode() {
      if (data.Length == 0) return 0;
      // HashCode must be same as int for values in the range of a single int
      if (IsNegative())
        return -(int)data[0];

      return (int)data[0];
    }

Usage Example

Exemple #1
0
        public static int __hash__(BigInteger self) {
#if CLR4 // TODO: we might need our own hash code implementation. This avoids assertion failure.
            if (self == -2147483648) {
                return -2147483648;
            }
#endif
            // Call the DLR's BigInteger hash function, which will return an int32 representation of
            // b if b is within the int32 range. We use that as an optimization for hashing, and 
            // assert the assumption below.
            int hash = self.GetHashCode();
#if DEBUG
            int i;
            if (self.AsInt32(out i)) {
                Debug.Assert(i == hash, String.Format("hash({0}) == {1}", i, hash));
            }
#endif
            return hash;
        }
All Usage Examples Of Microsoft.Scripting.Math.BigInteger::GetHashCode