Class Mult

java.lang.Object
org.jcsp.plugNplay.Mult
All Implemented Interfaces:
CSProcess

public final class Mult extends Object implements CSProcess
Scales an Integer stream.

Process Diagram

Description

Mult multiplies each Integer that flows through it by the multiplier with which it is configured.

Channel Protocols

Input Channels
in java.lang.Number The Channel can accept data from any subclass of Number. All values will be converted to ints.
Output Channels
out java.lang.Integer The output will always be of type Integer.

Example

The following example shows how to use the Mult process in a small program. The program also uses some of the other plugNplay processes. The program generates a sequence of Integers, multiplies them by 42 and prints this on the screen.
 import org.jcsp.lang.*;
 import org.jcsp.plugNplay.*;
 
 public class MultExample {
 
   public static void main (String[] argv) {
 
     final One2OneChannel a = Channel.one2one ();
     final One2OneChannel b = Channel.one2one ();
 
     new Parallel (
       new CSProcess[] {
         new Numbers (a.out ()),
         new Mult (42, a.in (), b.out ()),
         new Printer (b.in (), "--> ", "\n")
       }
     ).run ();
 
   }
 
 }
 
  • Field Details

    • n

      private final int n
      The multiplier
    • in

      private final ChannelInput in
      The input Channel
    • out

      private final ChannelOutput out
      The output Channel
  • Constructor Details

    • Mult

      public Mult(int n, ChannelInput in, ChannelOutput out)
      Construct a new Mult process with the input Channel in and the output Channel out.
      Parameters:
      n - the multiplier
      in - the input channel
      out - the output channel
  • Method Details

    • run

      public void run()
      The main body of this process.
      Specified by:
      run in interface CSProcess