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


C# SiteCohorts.Remove方法代码示例

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


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

示例1: CohortsRemoved

        public void CohortsRemoved()
        {
            SiteCohorts cohorts = new SiteCohorts();
            const ushort initialBiomass = 40;

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

            int timeOfLastSucc = 0;
            for (int time = 1; time <= 50; time++) {
                //  Simulate the site being disturbed every 8 years which
                //  results in a new cohort being added.
                bool siteDisturbed = (time % 8 == 0);

                bool isSuccTimestep = (time % successionTimestep == 0);

                if (siteDisturbed || isSuccTimestep) {
                    cohorts.Grow((ushort) (time - timeOfLastSucc), activeSite,
                                 isSuccTimestep);
                    timeOfLastSucc = time;
                }

                if (siteDisturbed)
                    cohorts.AddNewCohort(poputrem, initialBiomass);
            }

            //  Expected sequence of cohort changes:
            //
            //        Time  Grow_________
            //        Last         Cohorts               New
            //  Time  Succ  years  afterwards            Cohort
            //  ----  ----  -----  ---------------       ------
            //    8     0     8                           1(40)
            //   16     8     8    9(48)                  1(40)
            //   20    16     4    20(95*)                       * = 48+3 + 40+3 + 1
            //   24    20     4    24(99)                 1(40)
            //   32    24     8    32(107),9(48)          1(40)
            //   40    32     8    40(115),20(103*)       1(40)  * = 48+7 + 40+7 + 1
            //   48    40     8    48(123),28(111),9(48)  1(40)

            expectedCohorts.Clear();
            expectedCohorts[poputrem] = new ushort[] {
                //  age  biomass
                    48,    123,
                    28,    111,
                     9,     48,
                     1,     40
            };
            Util.CheckCohorts(expectedCohorts, cohorts);

            //  Remove cohorts whose ages are between 10 and 30
            expectedSite = null;
            deadCohorts.Clear();
            cohorts.Remove(AgeBetween5And30);

            expectedCohorts.Clear();
            expectedCohorts[poputrem] = new ushort[] {
                //  age  biomass
                    48,    123,
                     1,     40
            };
            Util.CheckCohorts(expectedCohorts, cohorts);

            Assert.AreEqual(2, deadCohorts.Count);
            ushort[] cohortData = new ushort[] {
                //  age  biomass (in young to old order because Remove goes
                //                from back to front)
                     9,     48,
                    28,    111
            };
            for (int i = 0; i < deadCohorts.Count; i++) {
                ICohort deadCohort = deadCohorts[i];
                Assert.AreEqual(poputrem, deadCohort.Species);
                Assert.AreEqual(cohortData[i*2], deadCohort.Age);
                Assert.AreEqual(cohortData[i*2+1], deadCohort.Biomass);
            }
        }
开发者ID:LANDIS-II-Foundation,项目名称:Library-Biomass-Cohort,代码行数:77,代码来源:CohortDeath_Test.cs


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