20 import ca.uqac.lif.cep.Connector;
21 import ca.uqac.lif.cep.Pullable;
22 import ca.uqac.lif.cep.functions.Cumulate;
23 import ca.uqac.lif.cep.functions.CumulativeFunction;
24 import ca.uqac.lif.cep.tmf.QueueSource;
25 import ca.uqac.lif.cep.util.Numbers;
39 public static void main(String[] args)
42 QueueSource source =
new QueueSource().setEvents(1, 2, 3, 4, 5, 6);
43 Cumulate sum =
new Cumulate(
44 new CumulativeFunction<Number>(Numbers.addition));
45 Connector.connect(source, sum);
46 Pullable p = sum.getPullableOutput();
47 for (
int i = 0; i < 5; i++)
49 System.out.println(
"The event is: " + p.pull());
Use a cumulative processor to compute the sum of all events received so far.