3
3
//DO NOT EDIT!
4
4
//USE TRACER
5
5
public class TraceCollector {
6
- public static LongHashSet trace = new LongHashSet ();
6
+ public static LongCollection trace = new LongHashSet ();
7
7
public static LongArrayWrapper statics = new LongArrayWrapper ();
8
8
9
9
public static void jcInstructionCovered (long jcInstructionId ) {
@@ -13,12 +13,27 @@ public static void jcStaticFieldAccessed(long jcStaticFieldAccessId) {
13
13
statics .add (jcStaticFieldAccessId );
14
14
}
15
15
16
- public static class LongArrayWrapper {
16
+ public interface LongCollection {
17
+ void add (long key );
18
+
19
+ long [] getAllValues ();
20
+
21
+ boolean contains (long key );
22
+
23
+ int realSize ();
24
+
25
+ boolean isEmpty ();
26
+
27
+ void clear ();
28
+ }
29
+
30
+ public static class LongArrayWrapper implements LongCollection {
17
31
public long [] arr ;
18
32
public int size ;
19
33
20
- LongArrayWrapper () {
34
+ public LongArrayWrapper () {
21
35
arr = new long [10 ];
36
+ size = 0 ;
22
37
}
23
38
24
39
public void add (long el ) {
@@ -35,6 +50,31 @@ public void removeLast() {
35
50
size --;
36
51
}
37
52
53
+ public long [] getAllValues () {
54
+ long [] res = new long [size ];
55
+ for (int i = 0 ; i < size ; i ++) {
56
+ res [i ] = arr [i ];
57
+ }
58
+ return res ;
59
+ }
60
+
61
+ public boolean contains (long key ) {
62
+ for (int i = 0 ; i < size ; i ++) {
63
+ if (arr [i ] == key ) {
64
+ return true ;
65
+ }
66
+ }
67
+ return false ;
68
+ }
69
+
70
+ public int realSize () {
71
+ return size ;
72
+ }
73
+
74
+ public boolean isEmpty () {
75
+ return size == 0 ;
76
+ }
77
+
38
78
public void clear () {
39
79
for (int i = 0 ; i < size ; i ++) {
40
80
arr [i ] = 0 ;
@@ -52,8 +92,7 @@ private void resize() {
52
92
}
53
93
}
54
94
55
-
56
- public static class LongHashSet {
95
+ public static class LongHashSet implements LongCollection {
57
96
private static final int DEFAULT_CAPACITY = 1024 ;
58
97
private static final double DEFAULT_LOAD_FACTOR = 0.75 ;
59
98
0 commit comments