当前位置: 首页>>代码示例>>C#>>正文


C# UInt32.Clone方法代码示例

本文整理汇总了C#中System.UInt32.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# UInt32.Clone方法的具体用法?C# UInt32.Clone怎么用?C# UInt32.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.UInt32的用法示例。


在下文中一共展示了UInt32.Clone方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ComputeUtility

        /// <summary>
        /// implements the recomputing utility function. figures out what the utility for n would be if n flipped its state
        /// from its present state in S.
        /// </summary>
        /// <param name="BucketTable"></param>
        /// <param name="Best"></param>
        /// <param name="ChosenParent"></param>
        /// <param name="SecP"></param>
        /// <param name="S"></param>
        /// <param name="n"></param>
        /// <param name="L"></param>
        /// <param name="BestRelation"></param>
        /// <param name="W"></param>
        /// <returns></returns>
        public int ComputeUtility(List<UInt32>[][] BucketTable, List<UInt32>[] Best, UInt32[] param_ChosenParent, bool[] param_SecP, bool[] S, UInt32 n, int L, byte BestRelation, UInt16[] W)
        {
            if (L == 0)
                 return 0;//no utility for routing to itself

             int UNTilda = 0;//utility for S with n's state flipped

             Int32 CustomerTreeSize = 0;
             Int32 CustomerWeightedTreeSize = 0;
             Int32 PeerWeightedTreeSize = 0;
             Int32 ProviderWeightedTreeSize = 0;

             //DON'T LET US OVERWRITE THINGS; we can overwrite S and flip it back at the end.
             ChosenParent = (UInt32[])param_ChosenParent.Clone();
             SecP = (bool[])param_SecP.Clone();

             S[n] = !S[n];//reverse n's state (we revert this before we return).

             //update n's path. if it has options
             if (Best[n].Count > 1)
             {
                 if (S[n]) //n became secure it cares about security in picking its path
                     updateParentWorker(n, ref Best, ref S, ref SecP, ref ChosenParent);//, ref tieBreakSet);
                 else
                 {
                     //n became insecure; re-evaluate its path options from the set of all paths.
                     UInt32 newParent = Best[n][0];
                     ChosenParent[n] = newParent;
                 }
             }
              //   if (S[n])//can only have secP if n is secure. (using an and so we revoke SecP for n flipping back.
                 SecP[n] = S[n]&SecP[ChosenParent[n]];

             byte[] throughN = new byte[Constants._numASNs];

             for (int i = 0; i < Constants._numASNs; i++)
                 throughN[i] = 0;//empty value.

             for (int row = L + 1; row < BucketTable.GetLength(0); row++)
             {
                 foreach (int col in columns)
                 {
                     if (BucketTable[row][col] == null)
                         continue;
                     foreach (UInt32 i in BucketTable[row][col])
                     {
                         /*only secure nodes will change their parents based on security. We still need to update
                          * whether or not they gothrough n though because someone before them may have changed to go
                          * through n*/
                         if (Best[i].Count > 1)//update path *only* if you have options.
                             updateParentWorker(i, ref Best, ref S, ref SecP, ref ChosenParent);//, ref tieBreakSet);

                         if (S[i])//only say your path is secure if you are secure
                             SecP[i] = SecP[ChosenParent[i]];

                         /* done updating our parents need to update whether we go through n or not */

                         if (row == L + 1 && ChosenParent[i] == n && col == Destination._PROVIDERCOLUMN)
                             throughN[i] = CustomerOf;//i is a customer of N
                         else if (row == L + 1 && ChosenParent[i] == n && col == Destination._PEERCOLUMN)
                             throughN[i] = PeerOf;
                         else if (row == L + 1 && ChosenParent[i] == n && col == Destination._CUSTOMERCOLUMN)
                             throughN[i] = ProviderTo;//i is a provider to N
                         else if (row > (L + 1))
                             throughN[i] = throughN[ChosenParent[i]];

                         //update utility values on how we pass through n
                         switch (throughN[i])
                         {
                             case CustomerOf:
                                 CustomerTreeSize++;
                                 CustomerWeightedTreeSize += W[i];
                                 break;
                             case PeerOf:
                                 PeerWeightedTreeSize += W[i];
                                 break;
                             case ProviderTo:
                                 ProviderWeightedTreeSize += W[i];
                                 break;
                         }

                     }
                 }
             }

             S[n] = !S[n];//flip n back
//.........这里部分代码省略.........
开发者ID:valkiria88,项目名称:Astoria,代码行数:101,代码来源:Worker.cs

示例2: BNModExp

        /*	Computes y = x^e mod m */
        /*	Binary left-to-right method */
        public static UInt32[]  BNModExp( UInt32[] x, UInt32[] e, UInt32[] m, int nSize)
        {
            int nn = nSize <<1;
            UInt32 mask;
            var t1 = new UInt32[nn];
            var t2 = new UInt32[nn];
            var t3 = new UInt32[nn];
            var tm = m.Clone() as uint[];
            var y = new UInt32[nSize];

            BNSetEqual(tm, m, nSize);
            int n = BNSizeof(e, nSize);
            for (mask = _HIBITMASK_; mask > 0; mask >>= 1)
            {
                if ((e[n - 1] & mask) != 0)
                    break;
            }
            if (mask == 1)
            {
                mask = _HIBITMASK_;
                n--;
            }
            else
            {
                mask >>= 1;
            }

            BNSetEqual(y, x, nSize);

            while (n > 0)
            {
                BNSquare(t1, y, nSize);
                BNModuloTmp(y, t1, nn, tm, nSize, t2, t3);
                if ((mask & e[n - 1]) != 0)
                {
                    BNMultiply(t1, y, x, nSize);
                    BNModuloTmp(y, t1, nn, tm, nSize, t2, t3);
                }

                if (mask == 1)
                {
                    mask = _HIBITMASK_;
                    n--;
                }
                else
                {
                    mask >>= 1;
                }
            }
            return y;
        }
开发者ID:langhuihui,项目名称:csharprtmp,代码行数:53,代码来源:CryptLib.cs


注:本文中的System.UInt32.Clone方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。