Code Examples
A repository of 155 code examples for BeepBeep
basic.WindowEven Class Reference

Use a Window processor to perform a computation over a sliding window of events that are not numeric. More...

Static Public Member Functions

static void main (String[] args)
 

Detailed Description

Use a Window processor to perform a computation over a sliding window of events that are not numeric.

The chain of processors in this example can be represented graphically as:

Processor graph
Author
Sylvain Hallé Easy

Definition at line 40 of file WindowEven.java.

Member Function Documentation

◆ main()

static void basic.WindowEven.main ( String []  args)
static

Create a source of arbitrary numbers

Definition at line 42 of file WindowEven.java.

43  {
44  /// Create a source of arbitrary numbers
45  QueueSource source = new QueueSource().setEvents(2, 7, 1, 8, 2, 8, 1, 8, 2, 8);
46 
47  // Check if each number is even
48  ApplyFunction is_even = new ApplyFunction(Numbers.isEven);
49  Connector.connect(source, is_even);
50 
51  // Create a cumulate processor
52  Cumulate sum = new Cumulate(
53  new CumulativeFunction<Boolean>(Booleans.or));
54 
55  // Create a window processor of width 3, using sum as the
56  // processor to be used on each window. Connect it to is_even.
57  Window win = new Window(sum, 3);
58  Connector.connect(is_even, win);
59 
60  // Pull events from the window
61  Pullable p = win.getPullableOutput();
62  for (int i = 0; i < 10; i++)
63  {
64  System.out.println("Window #" + i + ": " + p.pull());
65  }
66  ///
67  }

The documentation for this class was generated from the following file: