- 浏览: 220703 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (209)
- database (25)
- java技巧 (25)
- TC总结 (4)
- J2EE (8)
- 算法 (6)
- blog (4)
- php (4)
- linux & mac (19)
- 其它技术 (4)
- javascript&ajax (26)
- 测试技术 (8)
- XML&HTML (2)
- ORM (hibernate ...) (11)
- eclipse (5)
- 技术书籍 (8)
- 项目管理,cmmi (3)
- 硬件技术 (1)
- REST, web service, web架构 (1)
- 卓有成效程序员 (2)
- qone开发 (1)
- Design (4)
- .net (5)
- SCM (4)
- css (23)
- programming languages (1)
- ide (2)
- CSS Patterns (18)
- security (1)
- android (5)
最新评论
-
Virtoway:
说到Angular JS刚读到一片美国构架师的文章关于使用An ...
angular js: angular.bind example -
08284008:
该毛线啊,一点解释的都没有,怎么看
Thread join() 用法 -
Rex86lxw:
在eclipse中我一直用Navigator查看编写代码的,可 ...
eclipse不能自动编译,不报错 -
mistake:
..............
Angular js scope: the child scope would inherit from the parent scope -
sparrow1314:
very good! thanks!
IE下JS调试工具
java 代码
- /**
- * <p>
- * This method simply orders the ranked query result by date.
- * </p>
- *
- * @param result ranked result to be ordered
- *
- * @return ordered result
- *
- * @throws OrderException if the order execution fails because of some reason.
- */
- public RankedQueryResult order(RankedQueryResult result) throws OrderException {
- SearcherHelper.checkNull(result, "result");
- // TreeMap(Key date, Value id) may be a choice to implement sort. But it has a problem. The
- // Date of two Documents may be equal. In that case, when put them into the Map,
- // one Document will be neglected and a bug is introduced.
- // Also, I tried Arrays.sort(rankedOrder,new Comparator(){}. But in this
- // case, we can not throw the DocumentRepositoryException from Document Repository in Comparator#compare.
- // What's more, every time it compares Date, it'll have to retrieve the Date from // the repository.
- // Finally, I decided to implement it this way.
- /**
- * An Object for WordSourceId Date pair for the convenience of sorting WordSourceId by Date.
- */
- final class IdDateObject {
- /** The WordSourceId this object related */
- private WordSourceId id;
- /** The Date of the WordSourceId */
- private Date date;
- /**
- * Constructor for the project with the related WordSourceId and its date.
- *
- * @param id the WordSourceId this object related
- * @param date the Date of the WordSourceId
- */
- IdDateObject(WordSourceId id, Date date) {
- this.id = id;
- this.date = date;
- }
- /**
- * Returns the date of the WordSourceId.
- *
- * @return the date of the WordSourceId
- */
- Date getDate() {
- return date;
- }
- /**
- * Returns the WordSourceId the object related.
- *
- * @return the WordSourceId the object related
- */
- WordSourceId getId() {
- return id;
- }
- }// end for final class IdDateObject
- // constructs the IdDateObject array
- WordSourceId[] rankedOrder = result.getRankedOrder();
- IdDateObject[] idDateObjects = new IdDateObject[rankedOrder.length];
- for (int i = 0; i < rankedOrder.length; i++) {
- idDateObjects[i] = new IdDateObject(rankedOrder[i], getDocumentDate(rankedOrder[i]));
- }
- // sort in idDateObjects
- Arrays.sort(idDateObjects, new Comparator() {
- /**
- * Compares two IdDateObject objects according to the Date.
- * <p>
- *
- * <pre>
- * If the local variable decreasing is true:
- * If two objects' creation Dates are equal, 0 will be returned.
- * If arg0 greater than arg1, a positive int is returned.
- * Else a negative is returned.
- * Else the local variable decreasing is false:
- * If two objects' creation Dates, 0 will be returned.
- * If arg0 greater than arg1, a negitive integer is returned.
- * Else a positive integer is returned.
- * </pre>
- *
- * @param arg0 the first WordSourceId to compare
- * @param arg1 the second WordSourceId to compare
- * @return an integer representing the compare result according the above rule
- * @throws ClassCastException if the arguments' types prevent them from being compared by this Comparator.
- */
- public int compare(Object arg0, Object arg1) {
- IdDateObject object1 = (IdDateObject) arg0;
- IdDateObject object2 = (IdDateObject) arg1;
- Date date0 = object1.getDate();
- Date date1 = object2.getDate();
- int result = date0.compareTo(date1);
- if (decreasing) {
- result *= -1;
- }
- return result;
- }
- });
- // retrieve sort result
- WordSourceId[] resultOrder = new WordSourceId[rankedOrder.length];
- for (int i = 0; i < idDateObjects.length; i++) {
- resultOrder[i] = idDateObjects[i].getId();
- }
- // create and return a new ranked query result ordered by date
- return new RankedQueryResult(result.getResult(), result.getAllRelevances(), resultOrder);
- }
评论
2 楼
geek87
2009-11-18
好东西有用。。呵呵
1 楼
talangniao
2007-07-09
不理解这里Arrays.sort(idDateObjects, new Comparator()
new Comparator这个从哪里得来得?
new Comparator这个从哪里得来得?
发表评论
-
IntelliJ IDEA Live Templates for Unit Testing
2017-12-12 17:29 331http://vansande.org/2015/03 ... -
memory management in java
2017-12-07 15:25 294https://www.journaldev.com/28 ... -
Easiest way to read write files in java 8
2017-10-25 15:46 425Path path = Paths.get(getClas ... -
Tomcat 在启动时开启调试
2017-03-31 11:47 648很容量找到怎么在tomcat中远程调试的文章。如 http ... -
java读取文件内容
2013-11-19 15:37 521//将要读的文件文件放在resources/xml/目 ... -
Will android (java) UUID.randomUUID() return repeated UUIDs?
2013-11-19 06:11 2276Theoretically, I don't think ... -
将一个文件由gbk 转成 utf-8
2010-08-11 21:02 1482public void transform(String f ... -
java Serialization
2009-06-29 11:09 669http://www.blogjava.net/orangel ... -
JAAS
2009-06-09 11:10 1040http://publib.boulder.ibm.com/i ... -
java读取文件的路径如何找的
2009-06-04 13:58 1510is = getClass().getClassLoad ... -
要到另一个目录下运行ant, .bat文件中调用ant
2009-05-21 09:50 3435<ant antfile="build.xml ... -
一个生成json字符串的类
2009-04-16 13:08 923public class UserProjWorkloadQu ... -
运用Calendar进行java日期处理
2009-03-21 16:58 3246取得时间点所在的日的起始时间和结束时间(From Quartz ... -
ant 用户手册
2009-01-07 11:04 696http://ant.apache.org/manual/in ... -
Thread join() 用法
2008-11-11 20:36 1905Thread[] cThreads = new Thread[ ... -
利用Serialization实现对象深拷贝
2007-10-25 22:54 864java 代码 private PersonA ... -
Form-Letter Programming
2007-09-10 20:54 912Form-Letter Programming VS Mess ... -
StringBuffer VS StringBuilder
2007-09-08 23:05 1336现在看了,知道了,太简单了,其实说白了,StringB ... -
使用java.util.Calendar返回间隔天数
2007-07-29 13:32 1733java 代码 ** * Calc ... -
由xml和Document的标准操作
2007-07-09 22:49 974xml 到Documetn java 代码 p ...
相关推荐
主要介绍了Java Arrays.sort和Collections.sort排序实现原理解析,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
主要介绍了JAVA基于Arrays.sort()实现数组升序和降序,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
个人研究所得,包含对其内部jdk源码的分析。 同时会结合ArrayList中对该两个方法的调用做进一步说明。...总结一句话:在允许的情况下,尽量调用System.arraycopy方法,实在不行再调用Arrays.copyOf方法。
Apress.PHP.Arrays.Single.Multi-dimensional.Associative.and.Object.Arrays.in.PHP.7.1484225554.rar 最新书籍,精讲PHP数组,文字版PDF
Arduino项目开发 Control_Arrays_Arrays.pdf Arduino项目开发 Control_Arrays_Arrays.pdf Arduino项目开发 Control_Arrays_Arrays.pdf Arduino项目开发 Control_Arrays_Arrays.pdf Arduino项目开发 Control_Arrays_...
Gain an in-depth understanding of PHP 7 arrays. After a quick overview of PHP 7, each chapter concentrates on single, multi-dimensional, associative, and object arrays. PHP Arrays is a first of its ...
Antenna Arrays.pdf
本文主要对Arrays.asList方法进行总结。具有很好的参考价值,下面跟着小编一起来看下吧
主要介绍了Java中的Arrays.sort()代码详解,涉及Arrays.sort()简单示例,策略模式,”super”的使用等相关内容,具有一定借鉴价值,需要的朋友可以参考下。
网络图片地址url集合arrays.xml文件
主要介绍了深入理解java中Arrays.sort()的用法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
Java Methods-Arrays.ppt
Introducing Structures and Cell Arrays.zip
NULL 博文链接:https://128kj.iteye.com/blog/1747459
Arrays.sort(int[] a, int fromIndex, int toIndex) 并行排序:JDK1.8新增 Arrays.parallelSort(int[] a) Arrays.parallelSort(int[] a, int fromIndex, int toIndex) 并行计算: JDK1.8新增 支持函数式编程 根据...
Calculate the mutual impedance in an infinite phased arrays.
数据结构严蔚敏chapter2arrays.ppt
Protein.Arrays,.Biochips,.and.Proteomics.-.Joanna.S.Albala
Arrays.asList、ArrayList的subList坑
C程序设计英文课件:CHAPTE 5 Pointer and Arrays.ppt