Line | |
---|
1 | package shineagent;
|
---|
2 |
|
---|
3 | import java.util.HashMap;
|
---|
4 | import java.util.Map;
|
---|
5 |
|
---|
6 | import geniusweb.issuevalue.Value;
|
---|
7 | import geniusweb.issuevalue.ValueSet;
|
---|
8 | import geniusweb.issuevalue.Bid;
|
---|
9 | import geniusweb.issuevalue.Domain;
|
---|
10 |
|
---|
11 | public class IssueCounter extends HashMap<String, HashMap<Value, Integer>> {
|
---|
12 | private Domain domain;
|
---|
13 | public IssueCounter(Domain domain) {
|
---|
14 | super();
|
---|
15 | this.domain = domain;
|
---|
16 | for (String issue : domain.getIssues()) {
|
---|
17 | ValueSet vs = domain.getValues(issue);
|
---|
18 | HashMap<Value, Integer> issueMap = new HashMap<>();
|
---|
19 | for(Value value : vs)
|
---|
20 | {
|
---|
21 | issueMap.put(value, 0);
|
---|
22 | }
|
---|
23 | this.put(issue, issueMap);
|
---|
24 | }
|
---|
25 | }
|
---|
26 |
|
---|
27 | public void addElement(Bid inputBid) {
|
---|
28 | for (String issue : domain.getIssues()) {
|
---|
29 | Value value = inputBid.getValue(issue);
|
---|
30 | if(value == null)
|
---|
31 | continue;
|
---|
32 | int newCount = this.get(issue).get(value) + 1;
|
---|
33 | this.get(issue).put(value, newCount);
|
---|
34 | }
|
---|
35 | }
|
---|
36 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.