aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/function
diff options
context:
space:
mode:
authorEduardo Pedroni <ep625@york.ac.uk>2014-02-03 23:23:55 +0000
committerEduardo Pedroni <ep625@york.ac.uk>2014-02-03 23:23:55 +0000
commitd9671c354080de20bba4f70438af9242c8ecd675 (patch)
treef76736a4cda70950cb54aff56054095bbc9b5c22 /src/jcgp/function
parent2343cc0e456e0306711c0a7218d3027f17cffee7 (diff)
Fixed FunctionSet issue, planned testbench evaluator interface, will implement tomorrow.
Diffstat (limited to 'src/jcgp/function')
-rw-r--r--src/jcgp/function/FunctionSet.java38
1 files changed, 20 insertions, 18 deletions
diff --git a/src/jcgp/function/FunctionSet.java b/src/jcgp/function/FunctionSet.java
index 30e1067..cbe2f05 100644
--- a/src/jcgp/function/FunctionSet.java
+++ b/src/jcgp/function/FunctionSet.java
@@ -1,37 +1,39 @@
package jcgp.function;
-import java.util.ArrayList;
-
-
+/**
+ *
+ * TODO: if function set flexibility is desired (i.e. add more functions as the program runs)
+ * an add function method should be created
+ * this would lead to concurrency problems, so tread lightly!
+ *
+ *
+ * @author Eduardo Pedroni
+ *
+ */
public class FunctionSet {
- private ArrayList<Function> functionList;
+ private Function[] functionList;
+ private int maxArity = 0;
public FunctionSet(Function ... functions) {
- functionList = new ArrayList<Function>(functions.length);
+ functionList = functions;
- for (int i = 0; i < functions.length; i++) {
- functionList.add(functions[i]);
+ for (Function function : functionList) {
+ if (function.getArity() > maxArity) {
+ maxArity = function.getArity();
+ }
}
+
}
public int getFunctionCount() {
- return functionList.size();
+ return functionList.length;
}
public Function getFunction(int index) {
- return functionList.get(index);
+ return functionList[index];
}
public int getMaxArity(){
-
- int maxArity = 0;
-
- for (Function function : functionList) {
- if (function.getArity() > maxArity) {
- maxArity = function.getArity();
- }
- }
-
return maxArity;
}
} \ No newline at end of file