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


C# BigInteger.GetHashCode方法代码示例

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


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

示例1: GenerateQuorums

        public static List<SortedSet<int>> GenerateQuorums(SortedSet<int> parties, int quorumCount, int countPerQuorum, BigInteger seed)
        {
            // ensure that every party will be in a quorum
            Debug.Assert(quorumCount * countPerQuorum >= parties.Count);

            List<SortedSet<int>> quorums = new List<SortedSet<int>>();

            int intSeed = seed.GetHashCode();
            //   Random randGen = new Random(intSeed);
            Random randGen = new Random(3);
            Dictionary<int, int> partyPositions = new Dictionary<int, int>();
            int pos = 0;
            foreach (int party in parties)
                partyPositions[pos++] = party;

            do
            {
                quorums.Clear();
                for (int i = 0; i < quorumCount; i++)
                {
                    quorums.Add(GenerateQuorum(randGen, countPerQuorum, parties.Count, partyPositions));
                }
            } while (!AreAllInQuorum(quorums, parties.Count));

            return quorums;
        }
开发者ID:mahdiz,项目名称:mpclib,代码行数:26,代码来源:QuorumGenerator.cs

示例2: ChainedBlock

        public ChainedBlock(UInt256 blockHash, UInt256 previousBlockHash, int height, BigInteger totalWork)
        {
            this._blockHash = blockHash;
            this._previousBlockHash = previousBlockHash;
            this._height = height;
            this._totalWork = totalWork;

            this.hashCode = blockHash.GetHashCode() ^ previousBlockHash.GetHashCode() ^ height.GetHashCode() ^ totalWork.GetHashCode();
        }
开发者ID:holinov,项目名称:BitSharp,代码行数:9,代码来源:ChainedBlock.cs

示例3: DefaultCtorWorks

		public void DefaultCtorWorks ()
		{
			var a = new BigInteger ();
			Assert.AreEqual (BigInteger.One, ++a, "#1");

			a = new BigInteger ();
			Assert.AreEqual (BigInteger.MinusOne, --a, "#2");

			a = new BigInteger ();
			Assert.AreEqual (BigInteger.MinusOne, ~a, "#3");

			a = new BigInteger ();
			Assert.AreEqual ("0", a.ToString (), "#4");

			a = new BigInteger ();
			Assert.AreEqual (true, a == a, "#5");

			a = new BigInteger ();
			Assert.AreEqual (false, a < a, "#6");

			a = new BigInteger ();
			Assert.AreEqual (true, a < 10l, "#7");

			a = new BigInteger ();
			Assert.AreEqual (true, a.IsEven, "#8");

			a = new BigInteger ();
			Assert.AreEqual (0, (int)a, "#9");

			a = new BigInteger ();
			Assert.AreEqual (0, (uint)a, "#10");

			a = new BigInteger ();
			Assert.AreEqual (0, (ulong)a, "#11");

			a = new BigInteger ();
			Assert.AreEqual (true, a.Equals (a), "#12");

			a = new BigInteger ();
			Assert.AreEqual (a, BigInteger.Min (a, a), "#13");

			a = new BigInteger ();
			Assert.AreEqual (a, BigInteger.GreatestCommonDivisor (a, a), "#14");

			a = new BigInteger ();
			Assert.AreEqual (BigInteger.Zero.GetHashCode (), a.GetHashCode (), "#15");
		}
开发者ID:koush,项目名称:mono,代码行数:47,代码来源:BigIntegerTest.cs


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