Line | |
---|
1 | package geniusweb.exampleparties.agentgg;
|
---|
2 |
|
---|
3 | import java.util.Comparator;
|
---|
4 |
|
---|
5 | import geniusweb.issuevalue.Value;
|
---|
6 |
|
---|
7 | /**
|
---|
8 | * importance unit . Contains importance of a {@link Value} of some issue. The
|
---|
9 | * values in this class are hard referenced and changed by the {@link ImpMap}.
|
---|
10 | */
|
---|
11 | public class impUnit {
|
---|
12 | public Value valueOfIssue;
|
---|
13 | public int weightSum = 0;
|
---|
14 | public int count = 0;
|
---|
15 | public double meanWeightSum = 0.0f; // counts #occurences of this value.
|
---|
16 |
|
---|
17 | public impUnit(Value value) {
|
---|
18 | this.valueOfIssue = value;
|
---|
19 | }
|
---|
20 |
|
---|
21 | public String toString() {
|
---|
22 | return String.format("%s %f", valueOfIssue, meanWeightSum);
|
---|
23 | }
|
---|
24 |
|
---|
25 | // Overriding the comparator interface
|
---|
26 | static class meanWeightSumComparator implements Comparator<impUnit> {
|
---|
27 | public int compare(impUnit o1, impUnit o2) {
|
---|
28 | if (o1.meanWeightSum < o2.meanWeightSum) {
|
---|
29 | return 1;
|
---|
30 | } else if (o1.meanWeightSum > o2.meanWeightSum) {
|
---|
31 | return -1;
|
---|
32 | }
|
---|
33 | return 0;
|
---|
34 | }
|
---|
35 | }
|
---|
36 |
|
---|
37 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.