aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/function/FunctionSet.java
diff options
context:
space:
mode:
authorEduardo Pedroni <ep625@york.ac.uk>2014-03-26 21:34:37 +0000
committerEduardo Pedroni <ep625@york.ac.uk>2014-03-26 21:34:37 +0000
commit2bf2d3ac2c578de481ecfd545d58be73c5628996 (patch)
treeec47cfeedaed5bf677cab1bc9e910782369fe127 /src/jcgp/function/FunctionSet.java
parentbc4fafb9d3c60993253f7e78c10338c901de653a (diff)
Node grid has been refactored a few times, settings pane is almost complete, console is all done.
Diffstat (limited to 'src/jcgp/function/FunctionSet.java')
-rw-r--r--src/jcgp/function/FunctionSet.java23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/jcgp/function/FunctionSet.java b/src/jcgp/function/FunctionSet.java
index 07b4ea4..49ff7e7 100644
--- a/src/jcgp/function/FunctionSet.java
+++ b/src/jcgp/function/FunctionSet.java
@@ -3,6 +3,7 @@ package jcgp.function;
import java.util.ArrayList;
import java.util.Iterator;
+
/**
*
* @author Eduardo Pedroni
@@ -14,14 +15,14 @@ public abstract class FunctionSet {
protected int maxArity;
protected String name;
-// public int getTotalFunctionCount() {
-// return functionList.length;
-// }
-
- public int getFunctionCount() {
+ public int getAllowedFunctionCount() {
return allowedFunctions.size();
}
+ public int getTotalFunctionCount() {
+ return functionList.length;
+ }
+
public Function getFunction(int index) {
return allowedFunctions.get(index);
}
@@ -35,14 +36,15 @@ public abstract class FunctionSet {
}
public void disableFunction(int index) {
- for (Iterator<Function> iterator = allowedFunctions.iterator(); iterator.hasNext();) {
- if (index < functionList.length) {
+ if (index < functionList.length) {
+ for (Iterator<Function> iterator = allowedFunctions.iterator(); iterator.hasNext();) {
Function function = (Function) iterator.next();
if (function == functionList[index]) {
iterator.remove();
}
}
-
+ } else {
+ throw new IndexOutOfBoundsException("Function " + index + " does not exist, the set only has " + functionList.length + " functions.");
}
}
@@ -51,4 +53,9 @@ public abstract class FunctionSet {
allowedFunctions.add(functionList[index]);
}
}
+
+ @Override
+ public String toString() {
+ return name;
+ }
} \ No newline at end of file