# 各位大虾们，散分了！

yygywqf 2010-04-09 07:52:12

Class A //对象
{
busiType;
proptis; //须序
value;
}

A a1 = new ("CC000",0,"aaa");
A a2 = new ("CC000",1,"bbb");
A a3 = new ("CC001",0,"aaa");
A a4 = new ("CC001",1,"bbb");
A a5 = new ("CC001",2,"ccc");
A a6 = new ("CC002",0,"aaa");
A a7 = new ("CC002",1,"aaa");
A a8 = new ("CC003",0,"aaa");
A a9 = new ("CC003",1,"aaa");

A a1 = new ("CC000",0,"aaa");
A a2 = new ("CC000",1,"bbb");

A a3 = new ("CC001",0,"aaa");
A a4 = new ("CC001",1,"bbb");
A a5 = new ("CC001",2,"ccc");

A a6 = new ("CC002",0,"aaa");
A a7 = new ("CC002",1,"aaa");

A a8 = new ("CC003",0,"aaa");
A a9 = new ("CC003",1,"aaa");

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

...全文
204 28 打赏 收藏 转发到动态 举报

28 条回复

zhangliang_88 2010-10-12
• 打赏
• 举报

vietor 2010-10-12
• 打赏
• 举报

too 少了。

• 打赏
• 举报

20分也叫散分？？？无解···
24K純帥 2010-10-12
• 打赏
• 举报

floydmoney 2010-10-12
• 打赏
• 举报

``````public class Test {
public static List<A> getMaxList(){
A a1 = new A("CC000",0,"aaa");
A a2 = new A("CC000",1,"bbb");
A a3 = new A("CC001",0,"aaa");
A a4 = new A("CC001",1,"bbb");
A a5 = new A("CC001",2,"ccc");
A a6 = new A("CC002",0,"aaa");
A a7 = new A("CC002",1,"aaa");
A a8 = new A("CC003",0,"aaa");
A a9 = new A("CC003",1,"aaa");
List<A> maxList = new ArrayList<A>();
return maxList;
}
public static void insertSort(List<A> list , A obj){
//首先判断元素是否小于第一个或大于最后一个
A minObj = list.get(0);
A maxObj = list.get(list.size()-1);
if(minObj.getProptis() > obj.getProptis()){
return;
}else if(maxObj.getProptis() < obj.getProptis()){
return;
}
//循环判断插入位置并插入元素
for(int i = 0 ; i < list.size() - 1 ; i ++){
//当前i对应位置的原始
A currentObj = list.get(i);
//当前i对应位置的下一个元素
A nextObj = list.get(i + 1);
if(obj.getProptis() > currentObj.getProptis() && obj.getProptis() < nextObj.getProptis()){
}
}
}

public static void main(String[] args){
List<A> maxList = Test.getMaxList();
Map<String , List<A>> resultMap = new HashMap<String , List<A>>();
for(A a : maxList){
if(resultMap.containsKey(a.getBusiType())){
Test.insertSort(resultMap.get(a.getBusiType()), a);
}else{
List<A> templist = new ArrayList<A>();
resultMap.put(a.getBusiType(), templist);
}
}

}
}
class A{
private String busiType;
private int proptis;//须序
private String value;

public A(String busiType, int proptis, String value) {
this.busiType = busiType;
this.proptis = proptis;
this.value = value;
}
public String getBusiType() {
return busiType;
}
public void setBusiType(String busiType) {
this.busiType = busiType;
}
public int getProptis() {
return proptis;
}
public void setProptis(int proptis) {
this.proptis = proptis;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}``````
brock220 2010-10-12
• 打赏
• 举报

• 打赏
• 举报

rj1094 2010-10-12
• 打赏
• 举报

ZZZ5512536 2010-10-12
• 打赏
• 举报

20分 够分么……
zlllyk110 2010-10-12
• 打赏
• 举报

• 打赏
• 举报

What？
upswjj 2010-10-11
• 打赏
• 举报

clariones 2010-10-11
• 打赏
• 举报

``````
A[] a = {new A(...), .... new A(...)};
Map<String, List<A>> map = new HashMap<String, List<A>>;
for(int i=0;i<a.length;i++){
String key = a[i].busiType;
List<A> list = map.get(key);
if (list == null){
list = new Vector<A>();
map.put(key, list);
}
}
``````

• 打赏
• 举报

liukelin 2010-10-02
• 打赏
• 举报

wuxiuxiang 2010-10-01
• 打赏
• 举报

• 打赏
• 举报

bbb332 2010-04-10
• 打赏
• 举报

joaryyu 2010-04-10
• 打赏
• 举报

niulei190922 2010-04-10
• 打赏
• 举报

62,584

• 近7日
• 近30日
• 至今