本文整理汇总了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);
}
}