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

Use a Window processor to perform a computation over a sliding window of events. 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.

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

Processor graph
Author
Sylvain Hallé Easy

Definition at line 38 of file WindowSimple.java.

Member Function Documentation

◆ main()

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

Create a source of arbitrary numbers

Definition at line 40 of file WindowSimple.java.

41  {
42  /// Create a source of arbitrary numbers
43  QueueSource source = new QueueSource().setEvents(1, 2, 3, 4, 5, 6);
44 
45  // Create a cumulate processor
46  Cumulate sum = new Cumulate(
47  new CumulativeFunction<Number>(Numbers.addition));
48 
49  // Create a window processor of width 3, using sum as the
50  // processor to be used on each window. Connect it to the source.
51  Window win = new Window(sum, 3);
52  Connector.connect(source, win);
53 
54  // Pull events from the window
55  Pullable p = win.getPullableOutput();
56  System.out.println("First window: " + p.pull());
57  System.out.println("Second window: " + p.pull());
58  System.out.println("Third window: " + p.pull());
59  ///
60  }

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