From 0c288cc1952809294c8d70d86b9f41b04878ac2e Mon Sep 17 00:00:00 2001 From: Eduardo Pedroni Date: Sun, 23 Mar 2014 18:05:13 +0000 Subject: Majorly refactored, node grid is fully implemented. About to attempt active path locking. --- src/jcgp/function/FunctionSet.java | 54 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/jcgp/function/FunctionSet.java (limited to 'src/jcgp/function/FunctionSet.java') diff --git a/src/jcgp/function/FunctionSet.java b/src/jcgp/function/FunctionSet.java new file mode 100644 index 0000000..07b4ea4 --- /dev/null +++ b/src/jcgp/function/FunctionSet.java @@ -0,0 +1,54 @@ +package jcgp.function; + +import java.util.ArrayList; +import java.util.Iterator; + +/** + * + * @author Eduardo Pedroni + * + */ +public abstract class FunctionSet { + protected Function[] functionList; + protected ArrayList allowedFunctions; + protected int maxArity; + protected String name; + +// public int getTotalFunctionCount() { +// return functionList.length; +// } + + public int getFunctionCount() { + return allowedFunctions.size(); + } + + public Function getFunction(int index) { + return allowedFunctions.get(index); + } + + public int getMaxArity(){ + return maxArity; + } + + public String getName() { + return name; + } + + public void disableFunction(int index) { + for (Iterator iterator = allowedFunctions.iterator(); iterator.hasNext();) { + if (index < functionList.length) { + Function function = (Function) iterator.next(); + if (function == functionList[index]) { + iterator.remove(); + } + } + + } + } + + public void enableFunction(int index) { + if (!allowedFunctions.contains(functionList[index])) { + allowedFunctions.add(functionList[index]); + } + } + } \ No newline at end of file -- cgit v1.2.3