aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/function
diff options
context:
space:
mode:
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