0

ITSPoI allowedPoi = j.next()を実行すると、次のエラーが表示されますallowedPoIs.remove(k)

java.util.ArrayList$Itr.checkForComodification での java.util.ConcurrentModificationException (不明なソース)

private Map<String,Integer> findClosest(Route tempRoute, List<ITSPoI> allowedPoIs, List<ITSPoI> tabulist) {  
    double cost,mincost = 999999999; 
    Map<String,Integer> closest = new HashMap<String,Integer>();

    for (int i=0; i<tempRoute.getPOIs().size(); i++)        {
        int k = 0;
        for(Iterator<ITSPoI> j = allowedPoIs.iterator(); j.hasNext(); )  {

            ITSPoI allowedPoi = j.next();
            if (!intabu(allowedPoi,tabulist))
            {
                try 
                {
                    cost = _cvrtw.getCostMatrix().getCost(tempRoute.getPOI(i).getNodeId(),allowedPoi.getNodeId());

                    if (cost<mincost){
                        mincost = cost;
                        closest.put("index",i);
                        closest.put("poi",k);
                        allowedPoIs.remove(k);

                    }
                } 
                catch (Exception e) 
                {
                    e.printStackTrace();
                }
            }
            k++; 
            } 
        }
    return closest; 
    }
4

1 に答える 1