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


C# IntRange类代码示例

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


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


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