20 import ca.uqac.lif.cep.Connector;
21 import static ca.uqac.lif.cep.Connector.INPUT;
22 import static ca.uqac.lif.cep.Connector.OUTPUT;
23 import ca.uqac.lif.cep.GroupProcessor;
24 import ca.uqac.lif.cep.Pullable;
25 import ca.uqac.lif.cep.functions.Constant;
26 import ca.uqac.lif.cep.functions.Cumulate;
27 import ca.uqac.lif.cep.functions.CumulativeFunction;
28 import ca.uqac.lif.cep.functions.Function;
29 import ca.uqac.lif.cep.functions.IdentityFunction;
30 import ca.uqac.lif.cep.functions.TurnInto;
31 import ca.uqac.lif.cep.tmf.QueueSource;
32 import ca.uqac.lif.cep.tmf.Slice;
33 import ca.uqac.lif.cep.util.Numbers;
59 public static void main(String[] args)
62 QueueSource source =
new QueueSource();
63 source.setEvents(1, 6, 4, 3, 2, 1, 9);
67 Function slicing_fct =
new IdentityFunction(1);
71 GroupProcessor counter =
new GroupProcessor(1, 1);
73 TurnInto to_one =
new TurnInto(
new Constant(1));
74 Cumulate sum =
new Cumulate(
new CumulativeFunction<Number>(Numbers.addition));
75 Connector.connect(to_one, sum);
76 counter.addProcessors(to_one, sum);
77 counter.associateInput(INPUT, to_one, INPUT);
78 counter.associateOutput(OUTPUT, sum, OUTPUT);
83 Slice slicer =
new Slice(slicing_fct, counter);
84 Connector.connect(source, slicer);
87 Pullable p = slicer.getPullableOutput();
88 for (
int i = 0; i < 10; i++)
91 System.out.println(o);
static void main(String[] args)
Use the SlicerMap to compute the sum of odd and even numbers separately.