Package org.jcsp.plugNplay
Class And
- java.lang.Object
-
- org.jcsp.plugNplay.And
-
- All Implemented Interfaces:
CSProcess
public final class And extends java.lang.Object implements CSProcess
Bitwise ands two Integer streams to one stream.Process Diagram
Description
This is a process with an infinite loop that waits for a Object of type Number to be sent down each of its input channels. The loop body then calculates the bitwise AND on the values of the two Numbers and writes the result as a new Integer to its output channel.Channel Protocols
Input Channels in0, in1 java.lang.Number Both channels can accept data from any subclass of Number. It is possible to send Floats down one channel and Integers down the other. However 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 And process in a small program. The program also uses some of the other building block processes. The program generates a sequence of numbers and rounds each odd number down to the nearest even number and prints this on the screen.import org.jcsp.lang.*; import org.jcsp.plugNplay.*; public class AndExample { public static void main (String[] argv) { final One2OneChannel a = Channel.one2one (); final One2OneChannel b = Channel.one2one (); final One2OneChannel c = Channel.one2one (); new Parallel ( new CSProcess[] { new Numbers (a.out ()), new Generate (b.out (), Integer.MAX_VALUE - 1), new And (a.in (), b.in (), c.out ()), new Printer (c.in (), "--> ", "\n") } ).run (); } }
-
-
Field Summary
Fields Modifier and Type Field Description private ChannelInput
in0
The first input Channelprivate ChannelInput
in1
The second input Channelprivate ChannelOutput
out
The output Channel
-
Constructor Summary
Constructors Constructor Description And(ChannelInput in0, ChannelInput in1, ChannelOutput out)
Construct a new And process with the input Channels in0 and in1 and the output Channel out.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
run()
The main body of this process.
-
-
-
Field Detail
-
in0
private ChannelInput in0
The first input Channel
-
in1
private ChannelInput in1
The second input Channel
-
out
private ChannelOutput out
The output Channel
-
-
Constructor Detail
-
And
public And(ChannelInput in0, ChannelInput in1, ChannelOutput out)
Construct a new And process with the input Channels in0 and in1 and the output Channel out. The ordering of the Channels in0 and in1 make no difference to the functionality of this process.- Parameters:
in0
- the first input Channelin1
- the second input Channelout
- the output Channel
-
-