20 import ca.uqac.lif.cep.Connector;
21 import ca.uqac.lif.cep.Pullable;
22 import ca.uqac.lif.cep.functions.ApplyFunction;
23 import ca.uqac.lif.cep.tmf.QueueSource;
24 import ca.uqac.lif.cep.util.Numbers;
39 public static void main (String[] args)
42 QueueSource source1 =
new QueueSource().setEvents(2, 7, 1, 8, 3);
43 QueueSource source2 =
new QueueSource().setEvents(3, 1, 4, 1, 6);
44 QueueSource source3 =
new QueueSource().setEvents(1, 1, 2, 3, 5);
45 ApplyFunction add =
new ApplyFunction(Numbers.addition);
46 Connector.connect(source1, 0, add, 0);
47 Connector.connect(source2, 0, add, 1);
48 ApplyFunction mul =
new ApplyFunction(Numbers.multiplication);
49 Connector.connect(source3, 0, mul, 0);
50 Connector.connect(add, 0, mul, 1);
51 Pullable p = mul.getPullableOutput();
52 for (
int i = 0; i < 5; i++)
54 float x = (Float) p.pull();
55 System.out.println(
"The event is: " + x);
Pipe multiple ApplyFunction processors to perform a more complex computation over a stream...