1 Star 0 Fork 0

WJH/wjh20162327_datastructure

Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
文件
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
cList.java 1.89 KB
Copy Edit Raw Blame History
WJH authored 2017-10-07 23:18 +08:00 . 实验1-2
import java.util.ArrayList;
import java.util.List;
/**
* Created by Administrator on 2017/10/7/007.
*/
public class cList {
ArrayList clist;
public List<? extends Comparable> mergeSortedList(List<? extends Comparable> aList,
List<? extends Comparable> bList){
//public static List<? extends Comparable> mergeSortedList(List<? extends Comparable> aList,
// List<? extends Comparable> bList)
clist = new ArrayList();
for(Comparable i:aList)
// for(Comparable i=0;i.compareTo(aList.size());i++) {
clist.add(i);
//}
for (Comparable i:bList)
//for(Comparable i=0;i<bList.length;i++)
clist.add(i);
Sort(clist);
return clist;
}
/*public void Sort(List<? extends Comparable> list){
int position,scan;
for(position = list.size();position>=0;position--){
for(scan = 0;scan<=position - 1;scan++)
if(list.get(scan).compareTo(list.get(scan+1)) < 0)
//swap(cList,scan,scan+1);
swap((List<Comparable>) list,scan,scan+1);
}
}*/
public void Sort(List<? extends Comparable> list){
int min;
for (int index = 0; index < list.size()-1; index++)
{
min = index;
for (int scan = index+1; scan < list.size(); scan++)
if (list.get(scan).compareTo(list.get(min)) < 0)
min = scan;
swap((List<Comparable>) list, min, index);
}
}
private static void swap ( List<Comparable> list, int index1, int index2)
{
Comparable temp = list.get(index1);
Comparable A = list.get(index2);
list.set(index1,A);
list.set(index2,temp);
}
public String toString() {
return "cList{" + "list=" + clist + '}';
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/WwJjHh/wjh20162327_datastructure.git
git@gitee.com:WwJjHh/wjh20162327_datastructure.git
WwJjHh
wjh20162327_datastructure
wjh20162327_datastructure
master

Search