日期:2014-05-20 浏览次数:20601 次
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class ListTest {
public static List<Map<String, String>> list = new ArrayList<Map<String, String>>();
public static void Insert(String area, String room, String speed, String controlled) {
String map_area, map_room;
if (list.size() > 0) {
for (int i = 0; i < list.size(); i++) {
Map<String, String> wordListMap = list.get(i);
map_area = wordListMap.get("area");
map_room = wordListMap.get("room");
if (map_area.equalsIgnoreCase(area) && map_room.equalsIgnoreCase(room)) {
list.remove(i);
System.out.println("--重复移除--");
i--;
}
}
Map<String, String> map = new HashMap<String, String>();
map.put("area", area);
map.put("room", room);
map.put("speed", speed);
map.put("controlled", controlled);
list.add(map);
} else {
Map<String, String> map = new HashMap<String, String>();
map.put("area", area);
map.put("room", room);
map.put("speed", speed);
map.put("controlled", controlled);
list.add(map);
}
}
/**
* @param args
*/
public static void main(String[] args) {
for(int i=0;i<5;i++){
Insert("area_"+i,i+"0"+i,"speed_"+i,"controlled_"+i);
}
for (int i = 0; i < list.size(); i++) {
Map<String, String> map = new HashMap<String, String>();