GetHashCode() public method

public GetHashCode ( ) : int
return int
示例#1
0
        public override int GetHashCode()
        {
            int hash = ((System.Int32)refLevel).GetHashCode();

            for (int i = 0; i < size(); i++)
            {
                //NOTE(ctsims): It looks like this is only using Integer to
                //get the hashcode method, but that method
                //is just returning the int value, I think, so
                //this should potentially just be replaced by
                //an int.
                System.Int32 mult = DataUtil.integer(getMultiplicity(i));
                if (i == 0 && mult == INDEX_UNBOUND)
                {
                    mult = DataUtil.integer(0);
                }

                hash ^= getName(i).GetHashCode();
                hash ^= mult.GetHashCode();

                if (predicates == null)
                {
                    continue;
                }
                int val = 0;

                for (XPathExpression xpe: predicates)
                {
                    hash ^= val;
                    hash ^= xpe.hashCode();
                    ++val;
                }
            }
            return(hash);
        }
示例#2
0
 public override int GetHashCode()
 {
     unchecked {
         var hashCode = X.GetHashCode();
         hashCode = (hashCode * 397) ^ Y.GetHashCode();
         hashCode = (hashCode * 397) ^ Z.GetHashCode();
         return(hashCode);
     }
 }
示例#3
0
        static StackObject* GetHashCode_4(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* ptr_of_this_method;
            StackObject* __ret = ILIntepreter.Minus(__esp, 1);
            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.Int32 instance_of_this_method = GetInstance(__domain, ptr_of_this_method, __mStack);

            var result_of_this_method = instance_of_this_method.GetHashCode();

            __ret->ObjectType = ObjectTypes.Integer;
            __ret->Value = result_of_this_method;
            return __ret + 1;
        }
示例#4
0
        internal Value(System.Int32 value, Parameterization p = Parameterization.Value)
            : base(value)
        {
            Original  = value;
            _clrType  = typeof(System.Int32);
            _hashCode = GetCrossTypeHashCode(_clrType, value.GetHashCode());

            Build = (buildContext, buildArgs) =>
            {
                // literal:
                return((p != Parameterization.None) ?
                       (value.Parameterize(buildContext, p) ?? Mapping.Build(value, Mapping.DefaultInt32Type)) :
                       Mapping.Build(value, Mapping.DefaultInt32Type));
            };
        }
示例#5
0
 static int GetHashCode(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         System.Int32 obj = (System.Int32)ToLua.CheckObject(L, 1, typeof(System.Int32));
         int          o   = obj.GetHashCode();
         LuaDLL.lua_pushinteger(L, o);
         ToLua.SetBack(L, 1, obj);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
示例#6
0
        public void Print()
        {
            System.Int32 i = new System.Int32();
            i = 23;
            Console.WriteLine(i.GetHashCode());
            Console.WriteLine(i.GetType());
            Console.WriteLine(i.GetTypeCode());
            Console.WriteLine(i.ToString());
            if (i.CompareTo(20) < 0)
                Console.WriteLine("{0} < 20", i);
            else if (i.CompareTo(20) == 0)
                Console.WriteLine("i equals 20");
            else
                Console.WriteLine("i > 20");
            Console.WriteLine(System.Int32.MinValue);
            Console.WriteLine(System.Int32.MaxValue);
            Console.WriteLine(System.Double.Epsilon);
            Console.WriteLine(System.Double.PositiveInfinity);
            Console.WriteLine(System.Double.NegativeInfinity);
            Console.WriteLine(System.Boolean.FalseString);
            Console.WriteLine(System.Boolean.TrueString);

            Console.WriteLine(System.Char.IsDigit('1'));
            Console.WriteLine(System.Char.IsLetter('9'));
            Console.WriteLine(System.Char.IsWhiteSpace("naynish chaughule", 7));
            Console.WriteLine(System.Char.IsPunctuation('?'));

            //parsing
            double d = System.Double.Parse("90.35");
            Console.WriteLine(d);
            System.Int64 longVar = Convert.ToInt64("43654703826562");
            Console.WriteLine(longVar);

            Console.WriteLine(System.Guid.NewGuid());
            System.DateTime dt = new DateTime(2012, 6, 04);
            Console.WriteLine(dt.ToLongDateString());
            Console.WriteLine(DateTime.Now.ToLongTimeString());
            Console.WriteLine(dt.DayOfWeek);
            Console.WriteLine(dt.AddMonths(5).ToLongDateString());
            Console.WriteLine("{0} {1} {2}", dt.Date, dt.DayOfYear, dt.IsDaylightSavingTime());

            TimeSpan ts = new TimeSpan(24, 30, 30);
            Console.WriteLine(dt.Add(ts).ToLongDateString());
            Console.WriteLine(ts.Subtract(new TimeSpan(2,30, 45)));
            NumericsDemo();
            WorkingWithStrings();
        }
 public bool runTest()
   {
   Console.Error.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer);
   int iCountErrors = 0;
   int iCountTestcases = 0;
   String strLoc = "Loc_000oo";
   short[] in2Arr = new Int16[10];
   int[] in4Arr = new Int32[5];
   Boolean[] boArr = new Boolean[3];
   int iHashCode1, iHashCode2;
   try {
   do
     {
     strLoc = "Loc_01hc";
     iCountTestcases++;
     in2Arr = new Int16[10];
     iHashCode1 = in2Arr.GetHashCode();
     iHashCode2 = in2Arr.GetHashCode();
     if(iHashCode1 != iHashCode2)
       {
       iCountErrors++;
       Console.WriteLine( s_strTFAbbrev+ ", Err_01hc! , Array.GetHashCode on a same instance twice result different value." );
       }
     strLoc = "Loc_02hc";
     iCountTestcases++;
     in4Arr = new Int32[5];
     iHashCode1 = in2Arr.GetHashCode();
     iHashCode2 = in4Arr.GetHashCode();
     if(iHashCode1 == iHashCode2)
       {
       iCountErrors++;
       Console.WriteLine( s_strTFAbbrev+ ", Err_02hc! , Array.GetHashCode on a different array type instances result same value." );
       }
     boArr = new Boolean[3];
     strLoc = "Loc_03hc";
     iCountTestcases++;
     iHashCode1 = in2Arr.GetHashCode();
     iHashCode2 = boArr.GetHashCode();
     if(iHashCode1 == iHashCode2)
       {
       iCountErrors++;
       Console.WriteLine( s_strTFAbbrev+ ", Err_03hc! , Array.GetHashCode on a different array type instances result same value." );
       }
     strLoc = "Loc_04hc";
     iCountTestcases++;
     Array Arr1 = Array.CreateInstance(typeof(double), 10);
     Array Arr2 = Array.CreateInstance(typeof(Single), 0);
     iHashCode1 = Arr1.GetHashCode();
     iHashCode2 = Arr2.GetHashCode();
     if( iHashCode1 == iHashCode2 )
       {
       iCountErrors++;
       Console.WriteLine( s_strTFAbbrev+ ", Err_04hc! , Array.GetHashCode on a different array type instances result same value." );
       }
     int[][] i4Arr = new int[3][];
     i4Arr[0] = new int[] {1, 2, 3};
     i4Arr[1] = new int[] {1, 2, 3, 4, 5, 6};
     i4Arr[2] = new int[] {1, 2, 3, 4, 5, 6, 7, 8, 9};
     strLoc = "Loc_05hc";
     iCountTestcases++;
     iHashCode1 = i4Arr.GetHashCode();
     iHashCode2 = i4Arr.GetHashCode();
     if( iHashCode1 != iHashCode2 )
       {
       iCountErrors++;
       Console.WriteLine( s_strTFAbbrev+ ", Err_05hc! , Array.GetHashCode on a same instance of jagged array should result same value." );
       }
     strLoc = "Loc_06hc";
     iCountTestcases++;
     string[,,,,,] strArr = new string[6,5,4,3,2,1];
     iHashCode2 = strArr.GetHashCode();
     if( iHashCode1 == iHashCode2 )
       {
       iCountErrors++;
       Console.WriteLine( s_strTFAbbrev+ ", Err_06hc! , Array.GetHashCode on a different array type instances result same value." );
       }
     } while (false);
   } catch (Exception exc_general ) {
   ++iCountErrors;
   Console.WriteLine(s_strTFAbbrev +", Error Err_8888yyy!  strLoc=="+ strLoc +", exc_general=="+exc_general);
   }
   if ( iCountErrors == 0 )
     {
     Console.Error.WriteLine( "paSs.   "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases);
     return true;
     }
   else
     {
     Console.Error.WriteLine("FAiL!   "+s_strTFPath+" "+s_strTFName+" ,inCountErrors=="+iCountErrors+" , BugNums?: "+s_strActiveBugNums );
     return false;
     }
   }
示例#8
0
 public override int GetHashCode()
 {
     return(min_x.GetHashCode() ^ max_x.GetHashCode() ^ min_y.GetHashCode() ^ max_y.GetHashCode());
 }
示例#9
0
 /// <summary>
 /// Gets a unique hash code for this instance.
 /// </summary>
 /// <returns>A hash code.</returns>
 public override int GetHashCode()
 {
     return(x.GetHashCode() ^ y.GetHashCode());
 }
示例#10
0
 /// <summary>
 /// Use id as hash code
 /// </summary>
 /// <returns>The hash code given by id</returns>
 public override int GetHashCode()
 {
     return(m_id.GetHashCode());
 }
示例#11
0
 public override int GetHashCode()
 {
     return((X.GetHashCode()) ^ (Y.GetHashCode() << 2) ^ (Z.GetHashCode() >> 2) ^ (W.GetHashCode()));
 }
示例#12
0
 /// <summary>
 /// Gets a unique hash code for this instance.
 /// </summary>
 /// <returns>A unique hash code.</returns>
 public override int GetHashCode()
 {
     return(requestType.GetHashCode() ^ width.GetHashCode() ^ height.GetHashCode() ^ horiResolution.GetHashCode() ^ vertResolution.GetHashCode());
 }
示例#13
0
文件: attotime.cs 项目: kwanboy/mcs
 public override int GetHashCode()
 {
     return(m_seconds.GetHashCode() ^ m_attoseconds.GetHashCode());
 }
示例#14
0
 public int GetHashCode(EdgeType aIssue)
 {
     return(typeId.GetHashCode());
 }
示例#15
0
 /// <summary>
 /// Gets a unique hash code for this instance.
 /// </summary>
 /// <returns>A hash code.</returns>
 public override int GetHashCode()
 {
     //TODO better hash algo
     return(xMin.GetHashCode() ^ yMin.GetHashCode() ^ xMax.GetHashCode() ^ yMax.GetHashCode());
 }