ec.cgp.functions
Class FunctionsParity

java.lang.Object
  extended by ec.cgp.functions.FunctionsParity
All Implemented Interfaces:
Functions

public class FunctionsParity
extends java.lang.Object
implements Functions

Function set for the even-n-parity problem.

Author:
David Oranchak, doranchak@gmail.com, http://oranchak.com

Field Summary
(package private) static int F_AND
          logical and
(package private) static int F_NAND
          logical nand
(package private) static int F_NOR
          logical nor
(package private) static int F_NOT
          logical not
(package private) static int F_OR
          logical or
 
Constructor Summary
FunctionsParity()
           
 
Method Summary
 int arityOf(int fn)
          Return the arity of the given function
 java.lang.Object callFunction(java.lang.Object[] inputs, int function, int numFunctions)
          Interpret the given function and apply it to the given inputs.
 java.lang.String functionName(int fn)
          Return a function name, suitable for display in expressions, for the given function.
 java.lang.String inputName(int inp, java.lang.Object val)
          Return the name, suitable for display, for the given input.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

F_AND

static int F_AND
logical and


F_OR

static int F_OR
logical or


F_NOT

static int F_NOT
logical not


F_NOR

static int F_NOR
logical nor


F_NAND

static int F_NAND
logical nand

Constructor Detail

FunctionsParity

public FunctionsParity()
Method Detail

callFunction

public java.lang.Object callFunction(java.lang.Object[] inputs,
                                     int function,
                                     int numFunctions)
Interpret the given function and apply it to the given inputs.

Specified by:
callFunction in interface Functions
Parameters:
inputs - The arguments passed to the function. It is possible that some or all of the arguments will be unused by some functions.
function - The function number. Every function number must map to a function.
numFunctions - The total number of functions available.
Returns:
the result of the function call

functionName

public java.lang.String functionName(int fn)
Return a function name, suitable for display in expressions, for the given function.

Specified by:
functionName in interface Functions
Parameters:
fn - The function number
Returns:
The descriptive function name that corresponds to this function number.

inputName

public java.lang.String inputName(int inp,
                                  java.lang.Object val)
Return the name, suitable for display, for the given input.

Specified by:
inputName in interface Functions
Parameters:
inp - The input number
val - Optional input value (needed if you want to display a constant value for this input)
Returns:
The descriptive input name that corresponds to this input.

arityOf

public int arityOf(int fn)
Return the arity of the given function

Specified by:
arityOf in interface Functions
Parameters:
fn - the function number
Returns:
The number of inputs this function expects.