• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IntRange类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IntRange的典型用法代码示例。如果您正苦于以下问题:C# IntRange类的具体用法?C# IntRange怎么用?C# IntRange使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IntRange类属于命名空间,在下文中一共展示了IntRange类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: GetRandomIntOnDifferentThreadsGetsDifferentResults

 public void GetRandomIntOnDifferentThreadsGetsDifferentResults()
 {
     var numberToGenerate = 1000;
     var intRange = new IntRange(1, 10);
     var task1 = Task.Factory.StartNew(() =>
         {
             var taskResults = new List<int>();
             for (int i = 0; i < numberToGenerate; ++i)
             {
                 taskResults.Add(Randomizer<int>.Create(intRange));
             }
             return taskResults;
         },
         TaskCreationOptions.LongRunning
     );
     var task2 = Task.Factory.StartNew(() =>
         {
             var taskResults = new List<int>();
             for (int i = 0; i < numberToGenerate; ++i)
             {
                 taskResults.Add(Randomizer<int>.Create(intRange));
             }
             return taskResults;
         },
         TaskCreationOptions.LongRunning
     );
     var results = Task.WhenAll(task1, task2).Result;
     var firstResults = results[0].Sum();
     var secondResults = results[1].Sum();
     Assert.NotEqual(firstResults, secondResults);
 }
开发者ID:Tynamix,项目名称:ObjectFiller.NET,代码行数:31,代码来源:RandomAccessTest.cs


示例2: GetNext

 protected override int GetNext(IntRange fromRange, int soFar)
 {
     Contract.Requires(!fromRange.IsFixed);
     Contract.Requires(soFar >= 0);
     Contract.Ensures(fromRange.IsIn(Contract.Result<int>()));
     return 0;
 }
开发者ID:nagyistoce,项目名称:Neuroflow,代码行数:7,代码来源:SelectionAlgorithm.cs


示例3: LogicalConnectionOptUnit

 public LogicalConnectionOptUnit(string id, int resolution, IntRange indexRange)
     : base(id, resolution, indexRange, CreateOptUnit())
 {
     Contract.Requires(!string.IsNullOrEmpty(id));
     Contract.Requires(resolution > 1);
     Contract.Requires(!indexRange.IsFixed && indexRange.MinValue >= 0);
 }
开发者ID:nagyistoce,项目名称:Neuroflow,代码行数:7,代码来源:LogicalConnectionOptUnit.cs


示例4: Run

        public static void Run()
        {
            // ExStart:ConvertRangeOfDjVuPagesToSeparateImages
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_DjVu();

            // Load a DjVu image
            using (DjvuImage image = (DjvuImage)Image.Load(dataDir + "Sample.djvu"))
            {
                // Create an instance of BmpOptions and Set BitsPerPixel for resultant images
                BmpOptions exportOptions = new BmpOptions();
                exportOptions.BitsPerPixel = 32;

                // Create an instance of IntRange and initialize it with range of pages to be exported
                IntRange range = new IntRange(0, 2);
                int counter = 0;
                foreach (var i in range.Range)
                {
                    // Save each page in separate file, as BMP do not support layering
                    exportOptions.MultiPageOptions = new DjvuMultiPageOptions(range.GetArrayOneItemFromIndex(counter));
                    image.Save(dataDir + string.Format("{0}_out.bmp", counter++), exportOptions);
                }
            }
            // ExEnd:ConvertRangeOfDjVuPagesToSeparateImages
        }
开发者ID:aspose-imaging,项目名称:Aspose.Imaging-for-.NET,代码行数:25,代码来源:ConvertRangeOfDjVuPagesToSeparateImages.cs


示例5: Calculate

    public static double Calculate(ISymbolicTimeSeriesPrognosisExpressionTreeInterpreter interpreter, ISymbolicExpressionTree solution, double lowerEstimationLimit, double upperEstimationLimit, ITimeSeriesPrognosisProblemData problemData, IEnumerable<int> rows, IntRange evaluationPartition, int horizon, bool applyLinearScaling) {
      var horizions = rows.Select(r => Math.Min(horizon, evaluationPartition.End - r));
      IEnumerable<double> targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows.Zip(horizions, Enumerable.Range).SelectMany(r => r));
      IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows, horizions).SelectMany(x => x);
      OnlineCalculatorError errorState;

      double mse;
      if (applyLinearScaling && horizon == 1) { //perform normal evaluation and afterwards scale the solution and calculate the fitness value        
        var mseCalculator = new OnlineMeanSquaredErrorCalculator();
        CalculateWithScaling(targetValues, estimatedValues, lowerEstimationLimit, upperEstimationLimit, mseCalculator, problemData.Dataset.Rows * horizon);
        errorState = mseCalculator.ErrorState;
        mse = mseCalculator.MeanSquaredError;
      } else if (applyLinearScaling) { //first create model to perform linear scaling and afterwards calculate fitness for the scaled model
        var model = new SymbolicTimeSeriesPrognosisModel((ISymbolicExpressionTree)solution.Clone(), interpreter, lowerEstimationLimit, upperEstimationLimit);
        model.Scale(problemData);
        var scaledSolution = model.SymbolicExpressionTree;
        estimatedValues = interpreter.GetSymbolicExpressionTreeValues(scaledSolution, problemData.Dataset, rows, horizions).SelectMany(x => x);
        var boundedEstimatedValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit);
        mse = OnlineMeanSquaredErrorCalculator.Calculate(targetValues, boundedEstimatedValues, out errorState);
      } else {
        var boundedEstimatedValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit);
        mse = OnlineMeanSquaredErrorCalculator.Calculate(targetValues, boundedEstimatedValues, out errorState);
      }

      if (errorState != OnlineCalculatorError.None) return Double.NaN;
      else return mse;
    }
开发者ID:thunder176,项目名称:HeuristicLab,代码行数:27,代码来源:SymbolicTimeSeriesPrognosisSingleObjectiveMeanSquaredErrorEvaluator.cs


示例6: IsOverlappingTest

        public void IsOverlappingTest( int min1, int max1, int min2, int max2, bool expectedResult )
        {
            IntRange range1 = new IntRange( min1, max1 );
            IntRange range2 = new IntRange( min2, max2 );

            Assert.AreEqual( expectedResult, range1.IsOverlapping( range2 ) );
        }
开发者ID:hungdluit,项目名称:aforge,代码行数:7,代码来源:IntRangeTest.cs


示例7: LogicalOptUnit

 protected LogicalOptUnit(string id, int resolution, IntRange indexRange, IEnumerable<OptUnit> units)
     : base(id, ExtendOptUnits(units, resolution, indexRange))
 {
     Contract.Requires(!string.IsNullOrEmpty(id));
     Contract.Requires(resolution > 1);
     Contract.Requires(!indexRange.IsFixed && indexRange.MinValue >= 0);
 }
开发者ID:nagyistoce,项目名称:Neuroflow,代码行数:7,代码来源:LogicalOptUnit.cs


示例8:

 ISet<int> ISelectionAlgorithm.Select(IntRange fromRange, int count)
 {
     Contract.Requires(!fromRange.IsFixed);
     Contract.Requires(count > 0 && fromRange.Size >= count);
     Contract.Ensures(Contract.Result<ISet<int>>() != null);
     Contract.Ensures(Contract.Result<ISet<int>>().Count == count);
     return null;
 }
开发者ID:nagyistoce,项目名称:Neuroflow,代码行数:8,代码来源:ISelectionAlgorithm.cs


示例9: ToRangeTest

        public void ToRangeTest( int iMin, int iMax, float fMin, float fMax )
        {
            IntRange iRange = new IntRange( iMin, iMax );
            Range range = iRange;

            Assert.AreEqual( fMin, range.Min );
            Assert.AreEqual( fMax, range.Max );
        }
开发者ID:hungdluit,项目名称:aforge,代码行数:8,代码来源:IntRangeTest.cs


示例10: AverageDist

 internal static unsafe double AverageDist(float* valueBuffer, IntRange errorBuffer)
 {
     double s = errorBuffer.Size;
     if (s == 0.0) return 0.0;
     double v = 0.0f;
     for (int i = errorBuffer.MinValue; i <= errorBuffer.MaxValue; i++) v += (float)Math.Pow(valueBuffer[i] * 0.5, 2.0);
     return v / s;
 }
开发者ID:nagyistoce,项目名称:Neuroflow,代码行数:8,代码来源:ValueBuffer.cs


示例11: Average

 internal static unsafe double Average(float* valueBuffer, IntRange errorBuffer)
 {
     double s = errorBuffer.Size;
     if (s == 0.0) return 0.0;
     double v = 0.0f;
     for (int i = errorBuffer.MinValue; i <= errorBuffer.MaxValue; i++) v += valueBuffer[i];
     return v / s;
 }
开发者ID:nagyistoce,项目名称:Neuroflow,代码行数:8,代码来源:ValueBuffer.cs


示例12: Zero

        internal static void Zero(float[] valueBuffer, IntRange range)
        {
            Contract.Requires(valueBuffer != null);
            Contract.Requires(valueBuffer.Length >= range.MinValue);
            Contract.Requires(valueBuffer.Length >= range.MaxValue);

            Array.Clear(valueBuffer, range.MinValue, range.Size);
        }
开发者ID:nagyistoce,项目名称:Neuroflow,代码行数:8,代码来源:ValueBuffer.cs


示例13: SetupRoom

	// This is an overload of the SetupRoom function and has a corridor parameter that represents the corridor entering the room.
	public void SetupRoom (IntRange widthRange, IntRange heightRange, int columns, int rows, Corridor corridor, bool hasKey)
	{
		this.hasKey = hasKey;

		// Set the entering corridor direction.
		enteringCorridor = corridor.direction;

		// Set random values for width and height.
		roomWidth = widthRange.Random;
		roomHeight = heightRange.Random;

		//set the location that the key will spawn in in the room.
		keyLocation.x = widthRange.Random;
		keyLocation.y = heightRange.Random;


		switch (corridor.direction)
		{
		// If the corridor entering this room is going north...
		case Direction.North:
			// ... the height of the room mustn't go beyond the board so it must be clamped based
			// on the height of the board (rows) and the end of corridor that leads to the room.
			roomHeight = Mathf.Clamp(roomHeight, 1, rows - corridor.EndPositionY);

			// The y coordinate of the room must be at the end of the corridor (since the corridor leads to the bottom of the room).
			yPos = corridor.EndPositionY;

			// The x coordinate can be random but the left-most possibility is no further than the width
			// and the right-most possibility is that the end of the corridor is at the position of the room.
			xPos = Random.Range (corridor.EndPositionX - roomWidth + 1, corridor.EndPositionX);

			// This must be clamped to ensure that the room doesn't go off the board.
			xPos = Mathf.Clamp (xPos, 0, columns - roomWidth);
			break;
		case Direction.East:
			roomWidth = Mathf.Clamp(roomWidth, 1, columns - corridor.EndPositionX);
			xPos = corridor.EndPositionX;

			yPos = Random.Range (corridor.EndPositionY - roomHeight + 1, corridor.EndPositionY);
			yPos = Mathf.Clamp (yPos, 0, rows - roomHeight);
			break;
		case Direction.South:
			roomHeight = Mathf.Clamp (roomHeight, 1, corridor.EndPositionY);
			yPos = corridor.EndPositionY - roomHeight + 1;

			xPos = Random.Range (corridor.EndPositionX - roomWidth + 1, corridor.EndPositionX);
			xPos = Mathf.Clamp (xPos, 0, columns - roomWidth);
			break;
		case Direction.West:
			roomWidth = Mathf.Clamp (roomWidth, 1, corridor.EndPositionX);
			xPos = corridor.EndPositionX - roomWidth + 1;

			yPos = Random.Range (corridor.EndPositionY - roomHeight + 1, corridor.EndPositionY);
			yPos = Mathf.Clamp (yPos, 0, rows - roomHeight);
			break;
		}
	}
开发者ID:hartmatthew07,项目名称:2D-Dungeon-Generator,代码行数:58,代码来源:Room.cs


示例14: SetUpRoom

    public int yPos; //y coordinate lower left tile of the room

    #endregion Fields

    #region Methods

    //setUp the first room
    public void SetUpRoom(IntRange widthRange, IntRange heightRange, int columns, int rows)
    {
        roomWidth = widthRange.Random;
        roomHeight = heightRange.Random;

        //set the x and y coordinates so that the first room is in the middle of the board
        xPos = Mathf.RoundToInt(columns / 2f - roomWidth / 2);
        yPos = Mathf.RoundToInt(rows / 2f - roomWidth / 2);
    }
开发者ID:Enojia,项目名称:TopDown-prototype,代码行数:16,代码来源:Room.cs


示例15: LogicGateOptUnit

 public LogicGateOptUnit(string id, int resolution, IntRange indexRange, ISet<LogicalOperation> operations)
     : base(id, resolution, IntRange.CreateInclusive(1, indexRange.MaxValue), CreateOptUnit(resolution, operations))
 {
     Contract.Requires(!string.IsNullOrEmpty(id));
     Contract.Requires(resolution > 1);
     Contract.Requires(!indexRange.IsFixed && indexRange.MinValue >= 0);
     Contract.Requires(operations != null);
     Contract.Requires(operations.Count > 0);
 }
开发者ID:nagyistoce,项目名称:Neuroflow,代码行数:9,代码来源:LogicGateOptUnit.cs


示例16: EqualityOperatorTest

        public void EqualityOperatorTest( int min1, int max1, int min2, int max2, bool areEqual )
        {
            IntRange range1 = new IntRange( min1, max1 );
            IntRange range2 = new IntRange( min2, max2 );

            Assert.AreEqual( range1.Equals( range2 ), areEqual );
            Assert.AreEqual( range1 == range2, areEqual );
            Assert.AreEqual( range1 != range2, !areEqual );
        }
开发者ID:hungdluit,项目名称:aforge,代码行数:9,代码来源:IntRangeTest.cs


示例17: Push

        internal void Push(NeuralComputationContext context, IntRange errors)
        {
            Contract.Requires(context != null);

            IncIdx(context);

            var v = errorVectors[context.ErrorVectorStack_Index];
            network.CopyBuffer(context, errors, v);
            context.ErrorVectorStack_HasVectors[context.ErrorVectorStack_Index] = true;
        }
开发者ID:nagyistoce,项目名称:Neuroflow,代码行数:10,代码来源:ErrorVectorStack.cs


示例18: enumerable_collection_has_expected_members

        public void enumerable_collection_has_expected_members()
        {
            var range = new IntRange(1, 5).ToArray();

            Assert.AreEqual(1, range[0]);
            Assert.AreEqual(2, range[1]);
            Assert.AreEqual(3, range[2]);
            Assert.AreEqual(4, range[3]);
            Assert.AreEqual(5, range[4]);
        }
开发者ID:CuriositySoftware,项目名称:curiosity-common,代码行数:10,代码来源:IntRangeTests.cs


示例19: SetupRoom

 public void SetupRoom(IntRange widthRange, IntRange heightRange, int columns, int rows)
 {
     roomWidth = widthRange.Random;
     roomHeight = heightRange.Random;
     
     Debug.Log(Mathf.RoundToInt(Mathf.RoundToInt(columns / 2f - roomWidth / 2f)));
     Debug.Log(Mathf.RoundToInt((rows / 2f - roomHeight / 2f)));
     
     xPos = Mathf.RoundToInt(columns / 2f - roomWidth / 2f);
     yPos = Mathf.RoundToInt(rows / 2f - roomHeight / 2f);
 }
开发者ID:Super-Goat-Herders,项目名称:ProjectGoat,代码行数:11,代码来源:Room.cs


示例20: GetNext

 protected override int GetNext(IntRange fromRange, int soFar)
 {
     if (Direction == SelectionDirection.FromTop)
     {
         return fromRange.MinValue + soFar;
     }
     else
     {
         return fromRange.MaxValue + soFar;
     }
 }
开发者ID:nagyistoce,项目名称:Neuroflow,代码行数:11,代码来源:BorderSelectionAlgorithm.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IntRect类代码示例发布时间:2022-05-24
下一篇:
C# IntPtr类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap