~ubuntu-branches/ubuntu/precise/jcsp/precise

« back to all changes in this revision

Viewing changes to src/jcsp-demos/doc-ex/jcsp/plugNplay/ints/MergeIntExample.java

  • Committer: Bazaar Package Importer
  • Author(s): Miguel Landaeta
  • Date: 2010-06-20 18:12:26 UTC
  • Revision ID: james.westby@ubuntu.com-20100620181226-8yg8d9rjjjiuy7oz
Tags: upstream-1.1-rc4
ImportĀ upstreamĀ versionĀ 1.1-rc4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import org.jcsp.lang.*;
 
2
import org.jcsp.util.ints.*;
 
3
import org.jcsp.plugNplay.ints.*;
 
4
 
 
5
public class MergeIntExample {
 
6
 
 
7
  public static void main (String[] argv) {
 
8
 
 
9
    final One2OneChannelInt[] a = Channel.one2oneIntArray (5);
 
10
    final One2OneChannelInt[] b = Channel.one2oneIntArray (4, new InfiniteBufferInt ());
 
11
    final One2OneChannelInt c = Channel.one2oneInt ();
 
12
    final One2OneChannelInt d = Channel.one2oneInt ();
 
13
 
 
14
    new Parallel (
 
15
      new CSProcess[] {
 
16
        new MultInt (2, a[0].in (), b[0].out ()),
 
17
        new MultInt (3, a[1].in (), b[1].out ()),
 
18
        new MultInt (5, a[2].in (), b[2].out ()),
 
19
        new MultInt (7, a[3].in (), b[3].out ()),
 
20
        new MergeInt (Channel.getInputArray (b), c.out ()),
 
21
        new PrefixInt (1, c.in (), d.out ()),
 
22
        new DeltaInt (d.in (), Channel.getOutputArray (a)),
 
23
        new PrinterInt (a[4].in (), "--> ", "\n")
 
24
      }
 
25
    ).run ();
 
26
 
 
27
  }
 
28
 
 
29
}