GetHashCode() public method

public GetHashCode ( ) : int
return int
Ejemplo n.º 1
0
 public void GetHashCodeTest()
 {
     BigInteger target = new BigInteger(); // TODO: Initialize to an appropriate value
     int expected = 0; // TODO: Initialize to an appropriate value
     int actual;
     actual = target.GetHashCode();
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
Ejemplo n.º 2
0
 public override int GetHashCode()
 {
     return(x.GetHashCode() ^ base.GetHashCode());
 }
Ejemplo n.º 3
0
 public override int GetHashCode()
 {
     return((_a.GetHashCode() / _b.GetHashCode()).GetHashCode());
 }
Ejemplo n.º 4
0
 public override int GetHashCode()
 {
     return(bigInt.GetHashCode() ^ scale);
 }
Ejemplo n.º 5
0
 public static int Hash(BigInteger /*!*/ self)
 {
     return(self.GetHashCode());
 }
Ejemplo n.º 6
0
 public override int GetHashCode() => UUID.GetHashCode() ^ Amount.GetHashCode() ^ Operation.GetHashCode();
Ejemplo n.º 7
0
        // IComparable required methods.

        /// <summary>
        /// (From zencoders implemementation)
        /// Method used to get the hash code according to the algorithm:
        /// http://stackoverflow.com/questions/16340/how-do-i-generate-a-hashcode-from-a-byte-array-in-c/425184#425184
        /// </summary>
        /// <returns>Integer representing the hashcode</returns>
        public override int GetHashCode()
        {
            return(id.GetHashCode());
        }
Ejemplo n.º 8
0
 public override int GetHashCode()
 {
     return(number.GetHashCode());
 }
Ejemplo n.º 9
0
 public override int GetHashCode()
 {
     return(amount.GetHashCode());
 }
Ejemplo n.º 10
0
 public override int GetHashCode()
 {
     return(Q.GetHashCode() ^ x.GetHashCodeExt(0, 8));
 }
Ejemplo n.º 11
0
 public override int GetHashCode()
 {
     return(curve.GetHashCode() ^ g.GetHashCode() ^ n.GetHashCode() ^ h.GetHashCode() ^ Arrays.GetHashCode(seed));
 }
Ejemplo n.º 12
0
 public override int GetHashCode() => Data.GetHashCode();
Ejemplo n.º 13
0
 public override int GetHashCode()
 {
     return(p.GetHashCode() ^ q.GetHashCode() ^ a.GetHashCode());
 }
Ejemplo n.º 14
0
 public override int GetHashCode()
 {
     return(IsIntegral ? bigIntValue.GetHashCode() : doubleValue.GetHashCode());
 }
Ejemplo n.º 15
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;
        }
Ejemplo n.º 16
0
 public override int GetHashCode()
 {
     return(_Satoshis.GetHashCode());
 }
Ejemplo n.º 17
0
        private static void VerifyComparison(BigInteger x, bool IsXNegative, BigInteger y, bool IsYNegative, int expectedResult)
        {
            bool expectedEquals = 0 == expectedResult;
            bool expectedLessThan = expectedResult < 0;
            bool expectedGreaterThan = expectedResult > 0;

            if (IsXNegative == true)
            {
                x = x * -1;
            }
            if (IsYNegative == true)
            {
                y = y * -1;
            }

            Assert.Equal(expectedEquals, x == y);
            Assert.Equal(expectedEquals, y == x);

            Assert.Equal(!expectedEquals, x != y);
            Assert.Equal(!expectedEquals, y != x);

            Assert.Equal(expectedEquals, x.Equals(y));
            Assert.Equal(expectedEquals, y.Equals(x));

            Assert.Equal(expectedEquals, x.Equals((Object)y));
            Assert.Equal(expectedEquals, y.Equals((Object)x));

            VerifyCompareResult(expectedResult, x.CompareTo(y), "x.CompareTo(y)");
            VerifyCompareResult(-expectedResult, y.CompareTo(x), "y.CompareTo(x)");

            if (expectedEquals)
            {
                Assert.Equal(x.GetHashCode(), y.GetHashCode());
                Assert.Equal(x.ToString(), y.ToString());
            }

            Assert.Equal(x.GetHashCode(), x.GetHashCode());
            Assert.Equal(y.GetHashCode(), y.GetHashCode());

            Assert.Equal(expectedLessThan, x < y);
            Assert.Equal(expectedGreaterThan, y < x);

            Assert.Equal(expectedGreaterThan, x > y);
            Assert.Equal(expectedLessThan, y > x);

            Assert.Equal(expectedLessThan || expectedEquals, x <= y);
            Assert.Equal(expectedGreaterThan || expectedEquals, y <= x);

            Assert.Equal(expectedGreaterThan || expectedEquals, x >= y);
            Assert.Equal(expectedLessThan || expectedEquals, y >= x);
        }
Ejemplo n.º 18
0
 public override int GetHashCode()
 {
     return(p.GetHashCode() ^ g.GetHashCode() ^ l);
 }
Ejemplo n.º 19
0
 public override int GetHashCode()
 {
     return(_Target.GetHashCode());
 }
Ejemplo n.º 20
0
 public override int GetHashCode() =>
 (Q.GetHashCode() ^ Arrays.GetHashCode(this.x, 0, 0x11));
Ejemplo n.º 21
0
 public override int GetHashCode()
 {
     return(certainty.GetHashCode() ^ publicExponent.GetHashCode());
 }
Ejemplo n.º 22
0
 public override int GetHashCode()
 {
     // ReSharper disable once ImpureMethodCallOnReadonlyValueField
     return(_value.GetHashCode());
 }
Ejemplo n.º 23
0
 public override int GetHashCode()
 {
     return(modulus.GetHashCode() ^ exponent.GetHashCode() ^ IsPrivate.GetHashCode());
 }
Ejemplo n.º 24
0
 public override int GetHashCode()
 {
     return(Q.GetHashCode() ^ Arrays.GetHashCode(this.x, 0, 8));
 }
Ejemplo n.º 25
0
 public override int GetHashCode()
 {
     return(characteristic.GetHashCode());
 }
Ejemplo n.º 26
0
 /// <summary>
 /// Gets a hash code for this.
 /// </summary>
 /// <returns>A hash code.</returns>
 public override int GetHashCode()
 {
     return(_numerator.GetHashCode() ^ _denominator.GetHashCode());
 }
Ejemplo n.º 27
0
 public override int GetHashCode()
 {
     return(Q.GetHashCode() ^ Arrays.GetHashCode(x, 0, 5));
 }
Ejemplo n.º 28
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public override int GetHashCode()
 {
     return(_bigIntValue.GetHashCode() ^ _decimalCount.GetHashCode());
 }
Ejemplo n.º 29
0
 public override int GetHashCode()
 {
     return(Value.GetHashCode());
 }
Ejemplo n.º 30
0
 public override int GetHashCode() => (int)((Scale + 31 * (long)IntVal.GetHashCode()) % 2147483647);
Ejemplo n.º 31
0
        private static void VerifyComparison(BigInteger x, BigInteger y, int expectedResult)
        {
            bool expectedEquals = 0 == expectedResult;
            bool expectedLessThan = expectedResult < 0;
            bool expectedGreaterThan = expectedResult > 0;

            Assert.Equal(expectedEquals, x == y);
            Assert.Equal(expectedEquals, y == x);

            Assert.Equal(!expectedEquals, x != y);
            Assert.Equal(!expectedEquals, y != x);

            Assert.Equal(expectedEquals, x.Equals(y));
            Assert.Equal(expectedEquals, y.Equals(x));

            Assert.Equal(expectedEquals, x.Equals((Object)y));
            Assert.Equal(expectedEquals, y.Equals((Object)x));

            VerifyCompareResult(expectedResult, x.CompareTo(y), "x.CompareTo(y)");
            VerifyCompareResult(-expectedResult, y.CompareTo(x), "y.CompareTo(x)");

            IComparable comparableX = x;
            IComparable comparableY = y;
            VerifyCompareResult(expectedResult, comparableX.CompareTo(y), "comparableX.CompareTo(y)");
            VerifyCompareResult(-expectedResult, comparableY.CompareTo(x), "comparableY.CompareTo(x)");

            VerifyCompareResult(expectedResult, BigInteger.Compare(x, y), "Compare(x,y)");
            VerifyCompareResult(-expectedResult, BigInteger.Compare(y, x), "Compare(y,x)");

            if (expectedEquals)
            {
                Assert.Equal(x.GetHashCode(), y.GetHashCode());
                Assert.Equal(x.ToString(), y.ToString());
            }

            Assert.Equal(x.GetHashCode(), x.GetHashCode());
            Assert.Equal(y.GetHashCode(), y.GetHashCode());

            Assert.Equal(expectedLessThan, x < y);
            Assert.Equal(expectedGreaterThan, y < x);

            Assert.Equal(expectedGreaterThan, x > y);
            Assert.Equal(expectedLessThan, y > x);

            Assert.Equal(expectedLessThan || expectedEquals, x <= y);
            Assert.Equal(expectedGreaterThan || expectedEquals, y <= x);

            Assert.Equal(expectedGreaterThan || expectedEquals, x >= y);
            Assert.Equal(expectedLessThan || expectedEquals, y >= x);
        }
Ejemplo n.º 32
0
		public override int GetHashCode()
        {
            return base.GetHashCode() ^ q.GetHashCode();
        }
Ejemplo n.º 33
0
        private static void VerifyComparison(BigInteger x, UInt64 y, int expectedResult)
        {
            bool expectedEquals = 0 == expectedResult;
            bool expectedLessThan = expectedResult < 0;
            bool expectedGreaterThan = expectedResult > 0;

            Assert.Equal(expectedEquals, x == y);
            Assert.Equal(expectedEquals, y == x);

            Assert.Equal(!expectedEquals, x != y);
            Assert.Equal(!expectedEquals, y != x);

            Assert.Equal(expectedEquals, x.Equals(y));

            VerifyCompareResult(expectedResult, x.CompareTo(y), "x.CompareTo(y)");

            if (expectedEquals)
            {
                Assert.Equal(x.GetHashCode(), ((BigInteger)y).GetHashCode());
                Assert.Equal(x.ToString(), ((BigInteger)y).ToString());
            }

            Assert.Equal(x.GetHashCode(), x.GetHashCode());
            Assert.Equal(((BigInteger)y).GetHashCode(), ((BigInteger)y).GetHashCode());

            Assert.Equal(expectedLessThan, x < y);
            Assert.Equal(expectedGreaterThan, y < x);

            Assert.Equal(expectedGreaterThan, x > y);
            Assert.Equal(expectedLessThan, y > x);

            Assert.Equal(expectedLessThan || expectedEquals, x <= y);
            Assert.Equal(expectedGreaterThan || expectedEquals, y <= x);

            Assert.Equal(expectedGreaterThan || expectedEquals, x >= y);
            Assert.Equal(expectedLessThan || expectedEquals, y >= x);
        }
Ejemplo n.º 34
0
 public override int GetHashCode()
 {
     // A better hashCode is possible, but this works for now.
     return(_header.GetHashCode() ^ _chainWork.GetHashCode() ^ (int)_height);
 }
Ejemplo n.º 35
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

            // check if it's in the Int64 or UInt64 range, and use the built-in hashcode for that instead
            // this ensures that objects added to dictionaries as (U)Int64 can be looked up with Python longs
            Int64 i64;
            if (self.AsInt64(out i64)) {
                return Int64Ops.__hash__(i64);
            } else {
                UInt64 u64;
                if (self.AsUInt64(out u64)) {
                    return UInt64Ops.__hash__(u64);
                }
            }

            // 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;
        }
Ejemplo n.º 36
0
 int IEcmaValueBinder.GetHashCode(EcmaValueHandle handle)
 {
     return(value.GetHashCode());
 }