package com.junglesong;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;
public class Student implements Comparable{
private String name;
private int score;
public Student(String name,int score){
this.name=name;
this.score=score;
}
public int compareTo(Object obj){
Student another=(Student)obj;
return this.score-another.score;
}
public String toString(){
return "学生姓名="+name+" 分数="+score;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getScore() {
return score;
}
public void setScore(int score) {
this.score = score;
}
public static void main(String[] args){
//-----------老排序方案-----------
/*TimeTest oldSortTest=new TimeTest();
List<Student> scores=new ArrayList<Student>();
Random random=new Random();
for(int i=0;i<100000;i++){
scores.add(new Student("学生"+i,random.nextInt(100)));
}
Collections.sort(scores);
//for(Student student:scores){
// System.out.println(student);
//}
oldSortTest.end("老排序方案耗时");*/
//-----------新排序方案-----------
TimeTest newSortTest=new TimeTest();
ScoreSorter sorter2=new ScoreSorter(100);
Random random=new Random();
for(int i=0;i<1000;i++){
sorter2.addStudent(new Student("学生"+i,random.nextInt(100)));
}
List<Student> ls=sorter2.getSortedScores();
//for(Student student:sorter2.getSortedScores()){
// System.out.println(student);
//}
newSortTest.end("新排序方案耗时");
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有