Skip to main content
deleted 9 characters in body
Source Link
vnp
  • 57.3k
  • 4
  • 51
  • 140

Consider having 3 lists. One of modObj != null && modObj.isMod(). Another one of modObj != null && !modObj.isMod(). Third one of the rest (aka modObj == null). Finally join them. E.g.:

    List<Data> front_list = new ArrayList<>();
    List<Data> mid_list = new ArrayList<>();
    List<Data> tail_list = new ArrayList<>();

    for (Data d: basicData) {
        Data modObj = modData.get(d.getId());
        if (modObj == null) {
            tail_list.appendadd(d);
        } else if (modObj.isMod()) {
            front_list.appendadd(modObj);
        } else {
            mid_list.appendadd(modObj);
        }
    }

Consider having 3 lists. One of modObj != null && modObj.isMod(). Another one of modObj != null && !modObj.isMod(). Third one of the rest (aka modObj == null). Finally join them. E.g.:

    List<Data> front_list = new ArrayList<>();
    List<Data> mid_list = new ArrayList<>();
    List<Data> tail_list = new ArrayList<>();

    for (Data d: basicData) {
        Data modObj = modData.get(d.getId());
        if (modObj == null) {
            tail_list.append(d);
        } else if (modObj.isMod()) {
            front_list.append(modObj);
        } else {
            mid_list.append(modObj);
        }
    }

Consider having 3 lists. One of modObj != null && modObj.isMod(). Another one of modObj != null && !modObj.isMod(). Third one of the rest (aka modObj == null). Finally join them. E.g.:

    List<Data> front_list = new ArrayList<>();
    List<Data> mid_list = new ArrayList<>();
    List<Data> tail_list = new ArrayList<>();

    for (Data d: basicData) {
        Data modObj = modData.get(d.getId());
        if (modObj == null) {
            tail_list.add(d);
        } else if (modObj.isMod()) {
            front_list.add(modObj);
        } else {
            mid_list.add(modObj);
        }
    }
Source Link
vnp
  • 57.3k
  • 4
  • 51
  • 140

Consider having 3 lists. One of modObj != null && modObj.isMod(). Another one of modObj != null && !modObj.isMod(). Third one of the rest (aka modObj == null). Finally join them. E.g.:

    List<Data> front_list = new ArrayList<>();
    List<Data> mid_list = new ArrayList<>();
    List<Data> tail_list = new ArrayList<>();

    for (Data d: basicData) {
        Data modObj = modData.get(d.getId());
        if (modObj == null) {
            tail_list.append(d);
        } else if (modObj.isMod()) {
            front_list.append(modObj);
        } else {
            mid_list.append(modObj);
        }
    }