Skip to content

Commit

Permalink
Introduce LongCollection interface for storing instrumentation traces
Browse files Browse the repository at this point in the history
  • Loading branch information
aartdem committed Dec 19, 2024
1 parent c5d3fbf commit f2d0afa
Showing 1 changed file with 44 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//DO NOT EDIT!
//USE TRACER
public class TraceCollector {
public static LongHashSet trace = new LongHashSet();
public static LongCollection trace = new LongHashSet();
public static LongArrayWrapper statics = new LongArrayWrapper();

public static void jcInstructionCovered(long jcInstructionId) {
Expand All @@ -13,12 +13,27 @@ public static void jcStaticFieldAccessed(long jcStaticFieldAccessId) {
statics.add(jcStaticFieldAccessId);
}

public static class LongArrayWrapper {
public interface LongCollection {
void add(long key);

long[] getAllValues();

boolean contains(long key);

int realSize();

boolean isEmpty();

void clear();
}

public static class LongArrayWrapper implements LongCollection {
public long[] arr;
public int size;

LongArrayWrapper() {
public LongArrayWrapper() {
arr = new long[10];
size = 0;
}

public void add(long el) {
Expand All @@ -35,6 +50,31 @@ public void removeLast() {
size--;
}

public long[] getAllValues() {
long[] res = new long[size];
for (int i = 0; i < size; i++) {
res[i] = arr[i];
}
return res;
}

public boolean contains(long key) {
for (int i = 0; i < size; i++) {
if (arr[i] == key) {
return true;
}
}
return false;
}

public int realSize() {
return size;
}

public boolean isEmpty() {
return size == 0;
}

public void clear() {
for (int i = 0; i < size; i++) {
arr[i] = 0;
Expand All @@ -52,8 +92,7 @@ private void resize() {
}
}


public static class LongHashSet {
public static class LongHashSet implements LongCollection {
private static final int DEFAULT_CAPACITY = 1024;
private static final double DEFAULT_LOAD_FACTOR = 0.75;

Expand Down

0 comments on commit f2d0afa

Please sign in to comment.