projects
/
fleet.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
28d9d71
)
ShipPool: rename ancestor->parent, make private
author
Adam Megacz
<adam@megacz.com>
Mon, 27 Jul 2009 03:23:02 +0000
(20:23 -0700)
committer
Adam Megacz
<adam@megacz.com>
Mon, 27 Jul 2009 03:23:02 +0000
(20:23 -0700)
src/edu/berkeley/fleet/loops/ShipPool.java
patch
|
blob
|
history
diff --git
a/src/edu/berkeley/fleet/loops/ShipPool.java
b/src/edu/berkeley/fleet/loops/ShipPool.java
index
82a5296
..
f120139
100644
(file)
--- a/
src/edu/berkeley/fleet/loops/ShipPool.java
+++ b/
src/edu/berkeley/fleet/loops/ShipPool.java
@@
-11,15
+11,15
@@
import static edu.berkeley.fleet.util.BitManipulations.*;
public class ShipPool implements Iterable<Ship> {
public final Fleet fleet;
public class ShipPool implements Iterable<Ship> {
public final Fleet fleet;
- public final ShipPool ancestor;
+ private ShipPool parent;
private HashSet<Ship> allocatedShips = new HashSet<Ship>();
public ShipPool(Fleet fleet) { this(fleet, null); }
private HashSet<Ship> allocatedShips = new HashSet<Ship>();
public ShipPool(Fleet fleet) { this(fleet, null); }
- public ShipPool(ShipPool ancestor) { this(ancestor.fleet, ancestor); }
- public ShipPool(Fleet fleet, ShipPool ancestor) {
+ public ShipPool(ShipPool parent) { this(parent.fleet, parent); }
+ public ShipPool(Fleet fleet, ShipPool parent) {
this.fleet = fleet;
this.fleet = fleet;
- this.ancestor = ancestor;
+ this.parent = parent;
}
public Iterator<Ship> iterator() { return allocatedShips.iterator(); }
}
public Iterator<Ship> iterator() { return allocatedShips.iterator(); }
@@
-35,8
+35,8
@@
public class ShipPool implements Iterable<Ship> {
/** allocate a ship */
public Ship allocateShip(String type) {
Ship ship = null;
/** allocate a ship */
public Ship allocateShip(String type) {
Ship ship = null;
- if (ancestor != null) {
- ship = ancestor.allocateShip(type);
+ if (parent != null) {
+ ship = parent.allocateShip(type);
} else {
for(int i=0; ; i++) {
ship = fleet.getShip(type, i);
} else {
for(int i=0; ; i++) {
ship = fleet.getShip(type, i);
@@
-54,7
+54,7
@@
public class ShipPool implements Iterable<Ship> {
if (!allocatedShips.contains(ship))
throw new RuntimeException("ship " + ship + " released but was not allocated");
allocatedShips.remove(ship);
if (!allocatedShips.contains(ship))
throw new RuntimeException("ship " + ship + " released but was not allocated");
allocatedShips.remove(ship);
- if (ancestor != null) ancestor.releaseShip(ship);
+ if (parent != null) parent.releaseShip(ship);
}
public void releaseAll() {
}
public void releaseAll() {