listindexof.java
来自「高质量Java程序设计 源代码」· Java 代码 · 共 36 行
JAVA
36 行
package net.betterjava.collection.performance.list;
import java.util.List;
import java.util.Collection;
import java.util.Collections;
public class ListIndexOf extends AbstractListTest {
public ListIndexOf() {
super();
int[][] i = { { 100, 100, 100, 100, 100 }, {
100, 100, 100, 100, 200 }, {
100, 100, 100, 100, 300 }, {
100, 100, 100, 100, 400 }, {
100, 100, 100, 100, 500 }
};
this.setLoopTable(i);
}
protected long runTestBody(int rpts, List innerList) {
Collection c = Collections.nCopies(rpts, "");
innerList.addAll(c);
innerList.add("index");
long elapse = System.currentTimeMillis();
for (int j = 0; j < rpts; j++) {
innerList.indexOf("index");
}
return System.currentTimeMillis() - elapse;
}
public static void main(String[] args) {
AbstractListTest test = new ListIndexOf();
test.run();
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?