1 package edu.berkeley.fleet.interpreter.ships;
2 import edu.berkeley.fleet.interpreter.*;
3 import edu.berkeley.fleet.*;
8 public class Sort2 extends InterpreterShip {
10 DataInbox ap = new DataInbox(this, "a");
11 DataInbox bp = new DataInbox(this, "b");
12 DataOutbox min = new DataOutbox(this, "min");
13 DataOutbox max = new DataOutbox(this, "max");
15 public Sort2(Interpreter fleet, String name) { super(fleet, name); }
17 public String getBalsaName() { return "sort2"; }
19 public void service() {
20 if (ap.dataReadyForShip() && bp.dataReadyForShip()) {
21 int a = ap.removeDataForShip();
22 int b = bp.removeDataForShip();
23 max.addDataFromShip(Math.max(a,b));
24 min.addDataFromShip(Math.min(a,b));