public int MarkCohorts(SpeciesCohorts speciescohort, AgeOnlyCohorts.ISpeciesCohortsDisturbance disturbance) { Landis.Library.AgeOnlyCohorts.SpeciesCohortBoolArray isSpeciesCohortDamaged = new AgeOnlyCohorts.SpeciesCohortBoolArray(); isSpeciesCohortDamaged.SetAllFalse(speciescohort.Count); disturbance.MarkCohortsForDeath(speciescohort, isSpeciesCohortDamaged); // Go backwards through list of cohort data, so the removal of an // item doesn't mess up the loop. int totalReduction = 0; for (int i = speciescohort.Count - 1; i >= 0; i--) { if (isSpeciesCohortDamaged[i]) { totalReduction += speciescohort[i].Biomass; Landis.Library.BiomassCohorts.Cohort.KilledByAgeOnlyDisturbance(speciescohort, speciescohort[i], disturbance.CurrentSite, disturbance.Type); Cohort.Died(speciescohort, speciescohort[i], disturbance.CurrentSite, disturbance.Type); cohorts.Remove(speciescohort[i]); } } return(totalReduction); }
//--------------------------------------------------------------------- /// <summary> /// Removes the cohorts that are completed removed by disturbance. /// </summary> /// <returns> /// The total biomass of all the cohorts damaged by the disturbance. /// </returns> public int MarkCohorts(AgeOnlyCohorts.ISpeciesCohortsDisturbance disturbance) { isSpeciesCohortDamaged.SetAllFalse(Count); disturbance.MarkCohortsForDeath(this, isSpeciesCohortDamaged); // Go backwards through list of cohort data, so the removal of an // item doesn't mess up the loop. isMaturePresent = false; int totalReduction = 0; for (int i = cohortData.Count - 1; i >= 0; i--) { if (isSpeciesCohortDamaged[i]) { Cohort cohort = new Cohort(species, cohortData[i]); totalReduction += cohort.Biomass; RemoveCohort(i, cohort, disturbance.CurrentSite, disturbance.Type); Cohort.KilledByAgeOnlyDisturbance(this, cohort, disturbance.CurrentSite, disturbance.Type); cohort = null; } else if (cohortData[i].Age >= species.Maturity) { isMaturePresent = true; } } return(totalReduction); }
public int MarkCohorts(AgeOnlyCohorts.ISpeciesCohortsDisturbance disturbance) { isSpeciesCohortDamaged.SetAllFalse(Count); disturbance.MarkCohortsForDeath(this, isSpeciesCohortDamaged); // Go backwards through list of cohort data, so the removal of an // item doesn't mess up the loop. int totalReduction = 0; for (int i = cohorts.Count - 1; i >= 0; i--) { if (isSpeciesCohortDamaged[i]) { totalReduction += cohorts[i].Biomass; Landis.Library.BiomassCohorts.Cohort.KilledByAgeOnlyDisturbance(this, cohorts[i], disturbance.CurrentSite, disturbance.Type); cohorts[i].IsAlive = false; Cohort.Died(this, cohorts[i], disturbance.CurrentSite, disturbance.Type); } } return(totalReduction); }