📄 xorfunction.java~
字号:
package es.pj.circuits.experiment;
/*
* XOrFunction.java
*
* Created on December 29, 2000, 3:14 PM
*/
import es.SampleData;
import es.experiment.ExperimentLib;
/**
*
* @author unknown
* @version
*/
public class XOrFunction implements BooleanFunction {
/** Creates new XOrFunction */
public XOrFunction() {
}
/** returns the result of this function given the inputs in the array
* @param inputs what values the inputs to the function have
*/
public boolean getResult(boolean[] inputs)
{
return ( inputs[ 0 ] ^ inputs[ 1 ] );
}
/** returns the amount of inputs needed to compute this function
*/
public int getNumOfInputs()
{
return 2;
}
/** returns a set of BitSets providing a good set of input samples
* to test this function. Test looks like: A B (DesQ)
* 1 0 (0)
* 0 0 (1)
* 0 1 (0)
* 1 1 (1)
*/
public SampleData[] getTestData()
{
int[] inputBitsA = { 0, 3 };
int[] inputBitsB = { 2, 3 };
int[][] bits = { inputBitsA, inputBitsB };
return ExperimentLib.bitsToSampleDatas( bits, 4 );
}
public String toString()
{
return "XORFunction";
}
public void setRandomSeed(long seed) {
ExperimentLib.setRandomSeed( seed );
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -