Work/java
Vector 에서 다중 remove() 시 hashmap 이용
승수
2010. 5. 11. 19:40
if(csnolist != null){ csnolist <- 삭제할 목록 리스트 값
HashMap map = new HashMap();
for(int k = 0; k < subs.size(); k++){ subs <- 백터
map.put(k,subs.elementAt(k)); map에 백터 값을 넣어 준다
}
int mapsize = map.size();
for(int i =0; i<csnolist.length; i++ ){
map.remove(Integer.parseInt(csnolist[i])); map에서 csnolist 리스트 값을 차례로 삭제 한다
}
subs.removeAllElements(); 백터 값을 모두 비운다
for(int y=0; y< mapsize; y++){
if(map.get(y) != null){ map에서 값이 있는 것만 백터에 다시 넣어 준다
subs.add(subs.size(),map.get(y));
}
}
session.setAttribute("subsList",subs);
}