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


C# SiteCohorts.Clone方法代码示例

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


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

示例1: Clone

        public void Clone()
        {
            SiteCohorts cohorts = new SiteCohorts();
            const ushort initialBiomass = 55;
            cohorts.AddNewCohort(abiebals, initialBiomass);

            mockCalculator.CountCalled = 0;
            mockCalculator.Change = 1;

            for (int time = successionTimestep; time <= 70; time += successionTimestep) {
                Util.Grow(cohorts, successionTimestep, activeSite, true);
                if (time % 20 == 0)
                    cohorts.AddNewCohort(abiebals, initialBiomass);
                if (time % 30 == 0)
                    cohorts.AddNewCohort(betualle, initialBiomass);
            }

            //  Expected cohort changes:
            //
            //  Time  Cohorts
            //  ----  -------
            //    0   abiebals 1(55)
            //   10   abiebals 10(65)
            //   20   abiebals 20(75) 1(55)
            //   30   abiebals 30(85) 10(65)
            //        betualle 1(55)
            //   40   abiebals 40(95) 20(75) 1(55)
            //        betualle 10(65)
            //   50   abiebals 50(105) 30(85) 10(65)
            //        betualle 20(75)
            //   60   abiebals 60(115) 40(95) 20(75) 1(55)
            //        betualle 30(85) 1(55)
            //   70   abiebals 70(125) 50(105) 30(85) 10(65)
            //        betualle 40(95) 10(65)
            expectedCohorts.Clear();
		    expectedCohorts[abiebals] = new ushort[] {
		        //  age  biomass
		            70,    125,
		            50,    105,
		            30,     85,
		            10,     65
		    };
		    expectedCohorts[betualle] = new ushort[] {
		        //  age  biomass
		            40,     95,
		            10,     65
		    };
		    Util.CheckCohorts(expectedCohorts, cohorts);

		    SiteCohorts clone = cohorts.Clone();
		    Util.CheckCohorts(expectedCohorts, clone);

		    //  Modify the original set of cohorts by growing them for 2 more
		    //  succession timesteps.  Check that clone doesn't change.
            for (int time = 80; time <= 90; time += successionTimestep) {
                Util.Grow(cohorts, successionTimestep, activeSite, true);
		    }
		    Util.CheckCohorts(expectedCohorts, clone);

            expectedCohorts.Clear();
		    expectedCohorts[abiebals] = new ushort[] {
		        //  age  biomass
		            90,    145,
		            70,    125,
		            50,    105,
		            30,     85
		    };
		    expectedCohorts[betualle] = new ushort[] {
		        //  age  biomass
		            60,    115,
		            30,     85
		    };
		    Util.CheckCohorts(expectedCohorts, cohorts);
        }
开发者ID:LANDIS-II-Foundation,项目名称:Libraries,代码行数:74,代码来源:SiteCohorts_Test.cs


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