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

Filter a trace by evaluating a simple condition on the events of that trace. More...

Static Public Member Functions

static void main (String[] args)
 

Detailed Description

Filter a trace by evaluating a simple condition on the events of that trace.

This example can be represented grahpically as:

Processor graph
Author
Sylvain Hallé Easy

Definition at line 41 of file FilterConditionSimple.java.

Member Function Documentation

◆ main()

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

Create a trace of dummy values

Definition at line 43 of file FilterConditionSimple.java.

44  {
45  /// Create a trace of dummy values
46  QueueSource source_values = new QueueSource();
47  source_values.setEvents(6, 5, 3, 8, 9, 2, 1, 7, 4);
48  // Fork the trace in two
49  Fork fork = new Fork(2);
50  connect(source_values, fork);
51  // Connect the first ("left") output of the fork into a filter
52  Filter filter = new Filter();
53  connect(fork, LEFT, filter, LEFT);
54  // Create a processor evaluating the function "is even"
55  ApplyFunction condition = new ApplyFunction(Numbers.isEven);
56  // Connect its input to the second output of the fork
57  connect(fork, RIGHT, condition, INPUT);
58  // Connect the condition as the second input of our filter
59  connect(condition, OUTPUT, filter, RIGHT);
60  // Get a reference to the filter's output pullable
61  Pullable p = filter.getPullableOutput();
62  // Pull 4 events from p. This will only output even events, and
63  // discard odd numbers
64  for (int i = 0; i < 4; i++)
65  {
66  int x = (Integer) p.pull();
67  System.out.printf("Output event #%d is %d\n", i, x);
68  }
69  ///
70  }

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