-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCells.java
52 lines (39 loc) · 929 Bytes
/
Cells.java
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
package op21.chess;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import op21.chess.Cell;
import op21.chess.ChessBoard;
public class Cells implements Iterator<Cell>{
private List<Cell> cells = new LinkedList<Cell>();
private ChessBoard cb;
private void reset(){
for(int i = 0; i < this.cb.getRows(); i++){
for(int j = 0; j < this.cb.getColumns(); j++){
this.cells.add(Cell.of(i, j));
}
}
}
public Cells(ChessBoard cb){
this.cb = cb;
this.reset();
}
public Cells(Cells cs) {
this.cells = new LinkedList<Cell>(cs.cells);
this.cb = cs.cb;
}
public boolean blacklist(List<Cell> banned){
return this.cells.removeAll(banned);
}
public boolean blacklist(Cell banned){
return this.cells.remove(banned);
}
@Override
public boolean hasNext() {
return !this.cells.isEmpty();
}
@Override
public Cell next() {
return this.cells.remove(0);
}
}