天天看点

list 转换 map

public static Map<String, List<PointHelp>> findByIdMap(PlanInfo plan) {

  Map<String, List<PointHelp>> map = new HashMap<String, List<PointHelp>>();

  List<PointHelp> helplist = plan.getPointList();

  List<PointHelp> list = null;

  int day = 1;

  for (int i = 0; i < helplist.size(); i++) {

   if (i == 0)

    list = new ArrayList<PointHelp>();

   day = helplist.get(i).getDday();

   list.add(helplist.get(i));

   int nday = i + 1;

   if (nday >= helplist.size() || helplist.get(nday).getDday() != day) {

    map.put(String.valueOf(day), list);

    list = new ArrayList<PointHelp>();

   }

  }

  return map;

 }