lots of changes to Marina test code, mostly for scan chain counters
[fleet.git] / misc / obsolete-ships / Sort2.java
1 package edu.berkeley.fleet.interpreter.ships;
2 import edu.berkeley.fleet.interpreter.*;
3 import edu.berkeley.fleet.*;
4
5 import java.util.*;
6 import java.io.*;
7
8 public class Sort2 extends InterpreterShip {
9
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");
14
15     public Sort2(Interpreter fleet, String name) { super(fleet, name); }
16
17     public String getBalsaName() { return "sort2"; }
18
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));
25         }
26     }
27
28 }