| Modifier and Type | Field and Description |
|---|---|
private Player |
owner |
private Player.UnitPredicate |
predicate |
private java.util.List<Unit> |
units |
| Constructor and Description |
|---|
UnitIterator(Player owner,
Player.UnitPredicate predicate)
Creates a new
UnitIterator. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
hasNext() |
Unit |
next() |
void |
remove() |
boolean |
remove(Unit u)
Removes a specific unit from this unit iterator.
|
void |
reset()
Reset the iterator.
|
boolean |
setNext(Unit unit)
Set the next valid unit.
|
private void |
update()
Update the internal units list with units that satisfy the
predicate.
|
private final Player owner
private final Player.UnitPredicate predicate
private final java.util.List<Unit> units
public UnitIterator(Player owner, Player.UnitPredicate predicate)
UnitIterator.owner - The Player that needs an iterator of it's
units.predicate - An object for deciding whether a Unit
should be included in the Iterator or not.private final void update()
public boolean setNext(Unit unit)
unit - The Unit to put at the front of the list.public boolean remove(Unit u)
u - The Unit to remove.public void reset()
public boolean hasNext()
hasNext in interface java.util.Iterator<Unit>public void remove()
remove in interface java.util.Iterator<Unit>