forked from meinicke/VarexJ
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDataCollect.java
More file actions
80 lines (68 loc) · 1.71 KB
/
DataCollect.java
File metadata and controls
80 lines (68 loc) · 1.71 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package gov.nasa.jpf.vm.va;
import java.util.*;
public class DataCollect {
public Integer numCopy = 0;
public StackHandler owner;
// change name
Integer size = 0;
Integer max = 0;
Integer min = 0;
Integer ave = 0;
Integer gmax = 0;
public DataCollect(StackHandler sh){
this.owner = sh;
}
public void set(Integer size, Integer min, Integer max, Integer ave) {
this.size = size;
this.max = max;
this.min = min;
this.ave = ave;
}
public void setMin(Integer min){
this.min = min;
}
public void push(){
calculate();
// System.out.println("PUSH");
// System.out.println(owner.toString());
// System.out.println(this.toString());
}
public void pop(){
calculate();
// System.out.println("POP");
// System.out.println(owner.toString());
// System.out.println(this.toString());
}
public void dup(){
calculate();
// System.out.println("DUP");
// System.out.println(owner.toString());
// System.out.println(this.toString());
}
public void calculate(){
List<Integer> temp = owner.getTop().toList();
Integer len = temp.size();
Integer sum = temp.get(0) + 1;
max = temp.get(0) + 1;
min = temp.get(0) + 1;
if(max > gmax){
gmax = max;
}
for(int i = 1; i < len; i++){
if(temp.get(i) + 1 > gmax){
this.gmax = temp.get(i) + 1;
}
if(temp.get(i) + 1 > max)
this.max = temp.get(i) + 1;
if(temp.get(i) + 1 < min){
this.min = temp.get(i) + 1;
}
sum += temp.get(i) + 1;
}
this.ave = sum/len;
this.size = len;
}
public String toString(){
return "The size is " + this.size + "\nMinimun elements is "+ this.min + "\nMaximum elements is " +this.max + "\nAverage is " + this.ave + "\nNumbers of copys " + this.numCopy + "\ngmax is "+ this.gmax+ "\n";
}
}