0.10.8-alpha
ca.uqac.lif.cep.functions.FunctionTree Class Reference

A Function object representing the composition of multiple functions together to form a "compound" function. More...

Public Member Functions

 FunctionTree (Function f)
 Creates a new function tree. More...
 
 FunctionTree (Function ... functions)
 Creates a new function tree, by specifying the root and its immediate children. More...
 
FunctionTree setChild (int index, Function f)
 Sets the i-th child of the tree. More...
 
void evaluate (Object[] inputs, Object[] outputs, Context context, EventTracker tracker)
 
void evaluate (Object[] inputs, Object[] outputs)
 
boolean evaluatePartial (Object[] inputs, Object[] outputs, Context context)
 
boolean evaluateLazy (Object[] inputs, Object[] outputs)
 
int getInputArity ()
 
int getOutputArity ()
 
void reset ()
 
synchronized FunctionTree duplicate (boolean with_state)
 Duplicates an object. More...
 
void getInputTypesFor (Set< Class<?>> classes, int index)
 
Class<?> getOutputTypeFor (int index)
 
String toString ()
 
Object printState ()
 
FunctionTree readState (Object o)
 
- Public Member Functions inherited from ca.uqac.lif.cep.functions.Function
void evaluate (Object[] inputs, Object[] outputs, Context context)
 Evaluates the outputs of the function, given some inputs. More...
 
abstract void evaluate (Object[] inputs, Object[] outputs, Context context, EventTracker tracker)
 Evaluates the outputs of the function, given some inputs. More...
 
void evaluate (Object[] inputs, Object[] outputs)
 Evaluates the outputs of the function, given some inputs. More...
 
boolean evaluatePartial (Object[] inputs, Object[] outputs, Context context)
 Evaluates the outputs of the function, given some inputs. More...
 
boolean evaluateLazy (Object[] inputs, Object[] outputs)
 Attempts a lazy evaluation of the function, given some inputs. More...
 
abstract int getInputArity ()
 Gets the function's input arity, i.e. More...
 
abstract int getOutputArity ()
 Gets the function's output arity, i.e. More...
 
void reset ()
 Resets the function to its initial state. More...
 
abstract void getInputTypesFor (Set< Class<?>> classes, int index)
 Populates the set of classes accepted by the function for its i-th input. More...
 
abstract Class<?> getOutputTypeFor (int index)
 Returns the type of the events produced by the function for its i-th output. More...
 
Future< Object[]> evaluateFast (Object[] inputs, Object[] outputs, Context context, ExecutorService service)
 Utility method that delegates the call to evaluate() More...
 
final Function duplicate ()
 Duplicates an object and sets it to its initial state. More...
 
abstract Function duplicate (boolean with_state)
 Duplicates an object. More...
 
Object print (ObjectPrinter<?> printer)
 
final Function read (ObjectReader<?> reader, Object o) throws FunctionException
 Reads the content of a function from a serialized object. More...
 

Protected Attributes

Function m_function
 The function to evaluate. More...
 
Function [] m_children
 The children function to evaluate first. More...
 

Additional Inherited Members

- Static Public Attributes inherited from ca.uqac.lif.cep.functions.Function
static final int s_maxInputArity = 10
 The maximum input arity that a function can have. More...
 
- Protected Member Functions inherited from ca.uqac.lif.cep.functions.Function
Object printState ()
 Produces an object that represents the state of the current function. More...
 
Function readState (Object o)
 Reads the state of a function and uses it to create a new instance. More...
 

Detailed Description

A Function object representing the composition of multiple functions together to form a "compound" function.

A function tree has a root, which consists of an m:m function. This function is connected to n children, which can be functions or function trees themselves. The drawing below depicts a function tree that composes multiplication and addition to form a more complex function of two arguments.

FunctionTree
Author
Sylvain Hallé
Since
0.3

Definition at line 43 of file FunctionTree.java.

Constructor & Destructor Documentation

◆ FunctionTree() [1/2]

ca.uqac.lif.cep.functions.FunctionTree.FunctionTree ( Function  f)

Creates a new function tree.

Parameters
fThe function to act as the root of the tree

Definition at line 61 of file FunctionTree.java.

◆ FunctionTree() [2/2]

ca.uqac.lif.cep.functions.FunctionTree.FunctionTree ( Function ...  functions)

Creates a new function tree, by specifying the root and its immediate children.

Parameters
functionsAn array of functions. The first element of the array is the function to act as the root of the tree. The size of the array must be n+1, where n is the input arity of that function. The remaining elements of the array are the functions that will be the children of the root in the resulting tree.

Definition at line 79 of file FunctionTree.java.

Member Function Documentation

◆ duplicate()

synchronized FunctionTree ca.uqac.lif.cep.functions.FunctionTree.duplicate ( boolean  with_state)

Duplicates an object.

Optionally, set the object into the same state as the source object.

Parameters
with_stateSet to true to replicate the object's state, false to create a new copy in the initial state.
Returns
Another object

Implements ca.uqac.lif.cep.Duplicable.

Definition at line 185 of file FunctionTree.java.

◆ evaluate() [1/2]

void ca.uqac.lif.cep.functions.FunctionTree.evaluate ( Object []  inputs,
Object []  outputs,
Context  context,
EventTracker  tracker 
)

Definition at line 106 of file FunctionTree.java.

◆ evaluate() [2/2]

void ca.uqac.lif.cep.functions.FunctionTree.evaluate ( Object []  inputs,
Object []  outputs 
)

Definition at line 119 of file FunctionTree.java.

◆ evaluateLazy()

boolean ca.uqac.lif.cep.functions.FunctionTree.evaluateLazy ( Object []  inputs,
Object []  outputs 
)

Definition at line 144 of file FunctionTree.java.

◆ evaluatePartial()

boolean ca.uqac.lif.cep.functions.FunctionTree.evaluatePartial ( Object []  inputs,
Object []  outputs,
Context  context 
)

Definition at line 125 of file FunctionTree.java.

◆ getInputArity()

int ca.uqac.lif.cep.functions.FunctionTree.getInputArity ( )

Definition at line 150 of file FunctionTree.java.

◆ getInputTypesFor()

void ca.uqac.lif.cep.functions.FunctionTree.getInputTypesFor ( Set< Class<?>>  classes,
int  index 
)

Definition at line 196 of file FunctionTree.java.

◆ getOutputArity()

int ca.uqac.lif.cep.functions.FunctionTree.getOutputArity ( )

Definition at line 168 of file FunctionTree.java.

◆ getOutputTypeFor()

Class<?> ca.uqac.lif.cep.functions.FunctionTree.getOutputTypeFor ( int  index)

Definition at line 212 of file FunctionTree.java.

◆ printState()

Object ca.uqac.lif.cep.functions.FunctionTree.printState ( )
Since
0.10.2

Definition at line 246 of file FunctionTree.java.

◆ readState()

FunctionTree ca.uqac.lif.cep.functions.FunctionTree.readState ( Object  o)

Definition at line 261 of file FunctionTree.java.

◆ reset()

void ca.uqac.lif.cep.functions.FunctionTree.reset ( )

Definition at line 174 of file FunctionTree.java.

◆ setChild()

FunctionTree ca.uqac.lif.cep.functions.FunctionTree.setChild ( int  index,
Function  f 
)

Sets the i-th child of the tree.

Parameters
indexThe index. The method does not check ranges, so an ArrayIndexOutOfBounds exception will be thrown if attempting to set a child in an invalid position.
fThe function
Returns
This tree

Definition at line 99 of file FunctionTree.java.

◆ toString()

String ca.uqac.lif.cep.functions.FunctionTree.toString ( )

Definition at line 218 of file FunctionTree.java.

Member Data Documentation

◆ m_children

Function [] ca.uqac.lif.cep.functions.FunctionTree.m_children
protected

The children function to evaluate first.

Definition at line 53 of file FunctionTree.java.

◆ m_function

Function ca.uqac.lif.cep.functions.FunctionTree.m_function
protected

The function to evaluate.

Definition at line 48 of file FunctionTree.java.


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