Last change
on this file was 1, checked in by Wouter Pasman, 6 years ago |
Initial import : Genius 9.0.0
|
File size:
1.1 KB
|
Rev | Line | |
---|
[1] | 1 | package agents.anac.y2014.AgentYK;
|
---|
| 2 |
|
---|
| 3 | import java.util.ArrayList;
|
---|
| 4 | import java.util.List;
|
---|
| 5 | import java.util.NoSuchElementException;
|
---|
| 6 |
|
---|
| 7 | import genius.core.Bid;
|
---|
| 8 | import genius.core.issue.Issue;
|
---|
| 9 |
|
---|
| 10 | public class BidElementIterator implements java.util.Iterator<BidElement>{
|
---|
| 11 | private Bid bid;
|
---|
| 12 | private List<Integer> issueNrs;
|
---|
| 13 | private int index;
|
---|
| 14 |
|
---|
| 15 | public BidElementIterator(Bid bid) {
|
---|
| 16 | this.bid = new Bid(bid);
|
---|
| 17 | this.issueNrs = new ArrayList<Integer>();
|
---|
| 18 | for(Issue issue:this.bid.getIssues()) {
|
---|
| 19 | this.issueNrs.add(issue.getNumber());
|
---|
| 20 | }
|
---|
| 21 | this.index = 0;
|
---|
| 22 | }
|
---|
| 23 |
|
---|
| 24 | @Override
|
---|
| 25 | public boolean hasNext() {
|
---|
| 26 | if(index <= (this.issueNrs.size() - 1)) {
|
---|
| 27 | return true;
|
---|
| 28 | } else {
|
---|
| 29 | return false;
|
---|
| 30 | }
|
---|
| 31 | }
|
---|
| 32 |
|
---|
| 33 | @Override
|
---|
| 34 | public BidElement next() throws NoSuchElementException{
|
---|
| 35 | if(this.hasNext()) {
|
---|
| 36 | int IssueNr = this.issueNrs.get(this.index++);
|
---|
| 37 | try {
|
---|
| 38 | return new BidElement(IssueNr, this.bid.getValue(IssueNr));
|
---|
| 39 | } catch(Exception e){}
|
---|
| 40 | } else {
|
---|
| 41 | throw new NoSuchElementException();
|
---|
| 42 | }
|
---|
| 43 | return null;
|
---|
| 44 | }
|
---|
| 45 |
|
---|
| 46 | @Override
|
---|
| 47 | public void remove() throws UnsupportedOperationException {
|
---|
| 48 | throw new UnsupportedOperationException();
|
---|
| 49 | }
|
---|
| 50 |
|
---|
| 51 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.