-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestSearch.java
More file actions
31 lines (30 loc) · 995 Bytes
/
TestSearch.java
File metadata and controls
31 lines (30 loc) · 995 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Random;
public class TestSearch {
public static void main(String[] args) {
ArrayList<Integer> arrayList = new ArrayList<>(300000);
for (int i = 0; i < 300000; i++) {
arrayList.add(i);
}
// Collections.shuffle(arrayList);
ArrayList<Integer> b = new ArrayList<>(100000);
for (int i = 100000; i < 200000; i++) {
b.add(i);
}
// Collections.shuffle(b);
Long start = System.currentTimeMillis();
int count = 0;
for (int i = 0; i< b.size(); i++) {
for (int j = 0; j < arrayList.size(); j++) {
if(b.get(i).equals(arrayList.get(j))){
count++;
break ;
}
}
}
long end = System.currentTimeMillis();
System.out.println(" time is "+(end-start)+"; count is "+count);
}
}