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

GetHashCode() public méthode

public GetHashCode ( ) : int
Résultat int
        public override int GetHashCode() {
            // The Object.GetHashCode function needs to be consistent with the Object.Equals function.
            // Languages that build on top of this may have a more flexible equality function and 
            // so may not be able to use this hash function directly.
            // For example, Python allows that c=Complex64(1.5, 0), f = 1.5f,  c==f.
            // so then the hash(f) == hash(c). Since the python (and other languages) can define an arbitrary
            // hash(float) function, the language may need to define a matching hash(complex) function for
            // the cases where the float and complex numbers overlap.
            return (int)real + (int)imag * 1000003;
        }

Usage Example

Exemple #1
0
 public static int __hash__(Complex x)
 {
     if (x.Imaginary() == 0)
     {
         return(DoubleOps.__hash__(x.Real));
     }
     return(x.GetHashCode());
 }