From d9671c354080de20bba4f70438af9242c8ecd675 Mon Sep 17 00:00:00 2001 From: Eduardo Pedroni Date: Mon, 3 Feb 2014 23:23:55 +0000 Subject: Fixed FunctionSet issue, planned testbench evaluator interface, will implement tomorrow. --- src/jcgp/function/FunctionSet.java | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) (limited to 'src/jcgp/function') 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 functionList; + private Function[] functionList; + private int maxArity = 0; public FunctionSet(Function ... functions) { - functionList = new ArrayList(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 -- cgit v1.2.3