在迭代循环时,有些项目会被遗漏

时间:2017-09-29 14:35:46

标签: ewam

我试图运行的方法如下所示,我尝试遍历GBP中的子合约,然后我有一个内部循环来迭代每个子合约中的coverage。

forEach curSubscribedSubContract in theSubContracts
   ; Avoid building empty contract node
   if subOptions.count > 0
      new(ParamProduct)
      new(ParamSubscribedProduct)
      forEach curOption in subOptions downTo 
         theProduct = curOption.GetProduct
         new(ListOfCoverages)
         if Motor.AreSameThings(theProduct, curSubscribedSubContract.GetProduct)
            ParamSubscribedProduct.InitParamFromObjectAtDate(curSubscribedSubContract, 
               AtDate)
            ParamProduct.Product = ParamSubscribedProduct
            ;Set Context for PlanDesign options
            AFCI_SLI.CoverageInContext = curOption
            covData = self._GetCoverageData(curOption, AtDate)
            ;Reset coverage context               
            AFCI_SLI.CoverageInContext = Nil
            ListOfCoverages.AppendObject(covData)
            if subOptions.RemoveObject(curOption)
            endIf
         endIf
         forEach curCoverageData in ListOfCoverages
            ParamProduct.Coverages[-1] = curCoverageData
         endFor
         dispose(ListOfCoverages)
      endFor
      _Result[-1] = ParamProduct
   endIf
endFor

1 个答案:

答案 0 :(得分:1)

是分包合同或子选项中缺少的项目吗?

我认为以下代码行与它有关:

if subOptions.RemoveObject(curOption)
endIf

我不确定从正在迭代的列表中删除对象是否是一个好习惯。

尝试从子选项的foreach循环中删除“向下”