aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/function/FunctionSet.java
diff options
context:
space:
mode:
authorEduardo Pedroni <ep625@york.ac.uk>2014-03-23 18:05:13 +0000
committerEduardo Pedroni <ep625@york.ac.uk>2014-03-23 18:05:13 +0000
commit0c288cc1952809294c8d70d86b9f41b04878ac2e (patch)
treeef9671b711fe665a3156594663c083595861a4e6 /src/jcgp/function/FunctionSet.java
parentd3527a63e12c0e5288f1e7d2e2dc18e61d16b760 (diff)
Majorly refactored, node grid is fully implemented. About to attempt active path locking.
Diffstat (limited to 'src/jcgp/function/FunctionSet.java')
-rw-r--r--src/jcgp/function/FunctionSet.java54
1 files changed, 54 insertions, 0 deletions
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<Function> 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<Function> 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