의 오래된 개체를 TreeMap<Integer, ArrayList<Station>>
의 업데이트 된 개체로 바꿔야합니다.ArrayList 업데이트 <Station>의 값이 TreeMap <Integer, ArrayList><Station>>
TreeMap>은 Station 개체의 일부만 ArrayList에 포함합니다.
누구든지 빠르고 원활하게이 작업을 수행 할 수있는 방법을 알고 있습니까? 내 응용 프로그램은 시간에 민감합니다. 처리 속도가 빠를수록 처리중인 많은 양의 데이터로 인해 처리 속도가 빨라집니다. 그것은 어떤 도움 인 경우
나는 여기에 내가했습니다 코드를 게시 할 수 있습니다
편집 :
public ArrayList<Station> smoothPingPong(ArrayList<Station> dados){
ArrayList<Station> pingPongs = new ArrayList<>();
TreeMap<Integer, ArrayList<Station>> tmap = new TreeMap<>();
int tmap_key = 0;
for(int i = 0; i<dados.size(); i++) {
if(dados.get(i).getPingPong() == 1) {
pingPongs.add(dados.get(i));
}
}
ArrayList<Station> next = new ArrayList<Station>();
for(Station d : pingPongs) {
if(!next.isEmpty() && next.get(next.size() - 1).getId() != d.getId() - 1) {
tmap.put(tmap_key++, next);
next = new ArrayList<Station>();
}
next.add(d);
}
if(!next.isEmpty()) {
tmap.put(tmap_key++, next);
}
for(Integer a : tmap.keySet()){
//Processes the treemap updating it
}
}
지금 내가 다시 갈 필요가 : 여기
코드입니다 ArrayList의 스테이션을 TreeMap에있는 스테이션으로 업데이트하십시오.
* "도움이된다면 여기에 코드를 게시 할 수 있습니다"* ... 예, 제발하십시오. – arshajii
코드가 추가되었습니다. 감사합니다. – dazito