Guava API学习之Ordering尖锐的比较器ITeye - AG环亚娱乐

Guava API学习之Ordering尖锐的比较器ITeye

2019年03月06日10时39分31秒 | 作者: 天薇 | 标签: | 浏览: 2688

List String abc = ImmutableList.of("a", "b", "c"); System.out.println(natural.isOrdered(abc)); System.out.println(natural.isStrictlyOrdered(abc)); System.out.println("isOrdered reverse :"+ natural.reverse().isOrdered(abc)); List String cba = ImmutableList.of("c", "b", "a"); System.out.println(natural.isOrdered(cba)); System.out.println(natural.isStrictlyOrdered(cba)); System.out.println(cba = natural.sortedCopy(cba)); System.out.println("max:"+natural.max(cba)); System.out.println("min:"+natural.min(cba)); System.out.println("leastOf:"+natural.leastOf(cba, 2)); System.out.println("naturalOrdering:"+ naturalOrdering.sortedCopy(list)); System.out.println("leastOf list:"+naturalOrdering.leastOf(list, 3)); System.out.println("greatestOf:"+naturalOrdering.greatestOf(list, 3)); System.out.println("reverse list :"+ naturalOrdering.reverse().sortedCopy(list)); System.out.println("isOrdered list :"+ naturalOrdering.isOrdered(list)); System.out.println("isOrdered list :"+ naturalOrdering.reverse().isOrdered(list)); list.add(null); System.out.println(" add null list:"+list); System.out.println("nullsFirst list :"+ naturalOrdering.nullsFirst().sortedCopy(list)); System.out.println("nullsLast list :"+ naturalOrdering.nullsLast().sortedCopy(list)); }

 

成果:

list:[peida, jerry, harry, eva, jhon, neron]
naturalOrdering:[eva, harry, jerry, jhon, neron, peida]
listtest:[1, 1, 1, 2]
false
naturalIntReduceOrdering:[1, 2, 3, 4, 5, 6, 7, 8, 9]
listReduce:[9, 8, 7, 6, 5, 4, 3, 2, 1]
isOrdered reverse :false
false
false
[a, b, c]
max:c
min:a
leastOf:[a, b]
naturalOrdering:[eva, harry, jerry, jhon, neron, peida]
leastOf list:[eva, harry, jerry]
greatestOf:[peida, neron, jhon]
reverse list :[peida, neron, jhon, jerry, harry, eva]
isOrdered list :false
isOrdered list :false
 add null list:[peida, jerry, harry, eva, jhon, neron, null]
nullsFirst list :[null, eva, harry, jerry, jhon, neron, peida]
nullsLast list :[eva, harry, jerry, jhon, neron, peida, null]
list:[peida, jerry, harry, eva, jhon, neron]
naturalOrdering:[eva, harry, jerry, jhon, neron, peida]
usingToStringOrdering:[eva, harry, jerry, jhon, neron, peida]
arbitraryOrdering:[jhon, harry, eva, jerry, peida, neron]

 

 

版权声明
本文来源于网络,版权归原作者所有,其内容与观点不代表AG环亚娱乐立场。转载文章仅为传播更有价值的信息,如采编人员采编有误或者版权原因,请与我们联系,我们核实后立即修改或删除。

猜您喜欢的文章