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