1 package edu.berkeley.fleet.ir;
4 import edu.berkeley.fleet.two.*;
5 import edu.berkeley.fleet.api.*;
6 import edu.berkeley.fleet.api.Instruction.*;
7 import edu.berkeley.fleet.api.Instruction.Set;
8 import edu.berkeley.fleet.api.Instruction.Set.*;
9 import static edu.berkeley.fleet.util.BitManipulations.*;
11 public class ShipPool implements Iterable<Ship> {
13 public final Fleet fleet;
15 public ShipPool(Fleet fleet) { this.fleet = fleet; }
17 private HashSet<Ship> allocatedShips = new HashSet<Ship>();
19 public Iterator<Ship> iterator() { return allocatedShips.iterator(); }
21 public Ship allocateShip(String name) {
23 Ship ship = fleet.getShip(name, i);
25 throw new RuntimeException("no more ships of type " + name);
26 if (allocatedShips.contains(ship)) continue;
27 allocatedShips.add(ship);