Test
程序员文章站
2022-05-30 16:10:21
...
BUBBLE(new Sortable() { public <T extends Comparable<T>> void sort(T[] array, boolean ascend) { int length = array.length; int lastExchangedIdx = 0; for (int i = 0; i < length; i++) { // mark the flag to identity whether exchange happened to false boolean isExchanged = false; // last compare and exchange happened before reaching index i int currOrderedIdx = lastExchangedIdx > i ? lastExchangedIdx : i; for (int j = length - 1; j > currOrderedIdx; j--) { int compare = array[j - 1].compareTo(array[j]); if (compare != 0 && compare > 0 == ascend) { exchange(array, j - 1, j); isExchanged = true; lastExchangedIdx = j; } } // if no exchange happen means array is already in order if (isExchanged == false) { break; } } } }),
推荐阅读
-
Shell脚本test命令使用总结和实例
-
JS正则表达式从入门到入土(9)—— test方法以及它的那些坑
-
解决js相同的正则多次调用test()返回的值却不同的问题
-
Google Test 安装
-
详解在vue-test-utils中mock全局对象
-
java.lang.NoSuchMethodError: cn.makangning.test.dao.Users.getUserBirthday()Ljava/sql/Date;
-
javascript 使用正则test( )第一次是 true,第二次是false
-
Win10 AV-Test的杀软大PK:Win10 Defender不再花瓶
-
MySQL test数据库的权限
-
SQLite3源码学习之test_vfs的共享内存机制讲解