Merging mk branch rev. 527: simplified equals methods for GP nodes
This commit is contained in:
parent
f29dae18c6
commit
045e6dbb82
@ -276,6 +276,13 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
|
||||
test("+(sum(x),abs(sin(*(x0,x3))))", solG5);
|
||||
test("-(abs(sum(x)),*(abs(-7.5),n))", solG5);
|
||||
|
||||
GPNodeConst n1 = new GPNodeConst(3.);
|
||||
GPNodeConst n2 = new GPNodeConst(7.);
|
||||
GPNodeAdd n3 = new GPNodeAdd();
|
||||
System.out.println(n1.equals(n2));
|
||||
System.out.println(n2.equals(n1));
|
||||
System.out.println(n1.equals(n3));
|
||||
|
||||
System.out.println(createNodeList());
|
||||
}
|
||||
|
||||
@ -478,11 +485,29 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
|
||||
|
||||
}
|
||||
|
||||
/** This method allows you to determine whether or not two subtrees
|
||||
* are actually the same.
|
||||
* @param obj The other subtree.
|
||||
* @return boolean if equal true else false.
|
||||
*/
|
||||
// public abstract boolean equals(Object obj);
|
||||
/** This method allows you to determine wehter or not two subtrees
|
||||
* are actually the same.
|
||||
* @param obj The other subtree.
|
||||
* @return boolean if equal true else false.
|
||||
*/
|
||||
public abstract boolean equals(Object obj);
|
||||
public boolean equals(Object obj) {
|
||||
if (obj.getClass().equals(this.getClass())) {
|
||||
AbstractGPNode node = (AbstractGPNode)obj;
|
||||
if (this.getArity()!=node.getArity()) return false;
|
||||
if (this.m_Nodes.length != node.m_Nodes.length) return false;
|
||||
for (int i = 0; i < this.m_Nodes.length; i++) {
|
||||
if (!this.m_Nodes[i].equals(node.m_Nodes[i])) return false;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,24 +18,6 @@ public class GPNodeAbs extends AbstractGPNode implements java.io.Serializable {
|
||||
for (int i = 0; i < node.m_Nodes.length; i++) this.m_Nodes[i] = (AbstractGPNode) node.m_Nodes[i].clone();
|
||||
}
|
||||
|
||||
/** This method allows you to determine wehter or not two subtrees
|
||||
* are actually the same.
|
||||
* @param obj The other subtree.
|
||||
* @return boolean if equal true else false.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof GPNodeAbs) {
|
||||
GPNodeAbs node = (GPNodeAbs)obj;
|
||||
if (this.m_Nodes.length != node.m_Nodes.length) return false;
|
||||
for (int i = 0; i < this.m_Nodes.length; i++) {
|
||||
if (!this.m_Nodes[i].equals(node.m_Nodes[i])) return false;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** This method will be used to identify the node in the GPAreaEditor
|
||||
* @return The name.
|
||||
*/
|
||||
|
@ -24,24 +24,6 @@ public class GPNodeAdd extends AbstractGPNode implements java.io.Serializable {
|
||||
for (int i = 0; i < node.m_Nodes.length; i++) this.m_Nodes[i] = (AbstractGPNode) node.m_Nodes[i].clone();
|
||||
}
|
||||
|
||||
/** This method allows you to determine wehter or not two subtrees
|
||||
* are actually the same.
|
||||
* @param obj The other subtree.
|
||||
* @return boolean if equal true else false.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof GPNodeAdd) {
|
||||
GPNodeAdd node = (GPNodeAdd)obj;
|
||||
if (this.m_Nodes.length != node.m_Nodes.length) return false;
|
||||
for (int i = 0; i < this.m_Nodes.length; i++) {
|
||||
if (!this.m_Nodes[i].equals(node.m_Nodes[i])) return false;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** This method will be used to identify the node in the GPAreaEditor
|
||||
* @return The name.
|
||||
*/
|
||||
|
@ -22,20 +22,15 @@ public class GPNodeConst extends AbstractGPNode implements java.io.Serializable
|
||||
for (int i = 0; i < node.m_Nodes.length; i++) this.m_Nodes[i] = (AbstractGPNode) node.m_Nodes[i].clone();
|
||||
}
|
||||
|
||||
/** This method allows you to determine wehter or not two subtrees
|
||||
* are actually the same.
|
||||
* @param obj The other subtree.
|
||||
* @return boolean if equal true else false.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof GPNodeConst) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof GPNodeConst) {
|
||||
GPNodeConst node = (GPNodeConst)obj;
|
||||
return (node.value==this.value);
|
||||
} else return false;
|
||||
}
|
||||
|
||||
/** This method will be used to identify the node in the GPAreaEditor
|
||||
/** This method will be used to identify the node in the GPAreaEditor
|
||||
* @return The name.
|
||||
*/
|
||||
public String getName() {
|
||||
|
@ -20,24 +20,6 @@ public class GPNodeCos extends AbstractGPNode implements java.io.Serializable {
|
||||
for (int i = 0; i < node.m_Nodes.length; i++) this.m_Nodes[i] = (AbstractGPNode) node.m_Nodes[i].clone();
|
||||
}
|
||||
|
||||
/** This method allows you to determine wehter or not two subtrees
|
||||
* are actually the same.
|
||||
* @param obj The other subtree.
|
||||
* @return boolean if equal true else false.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof GPNodeCos) {
|
||||
GPNodeCos node = (GPNodeCos)obj;
|
||||
if (this.m_Nodes.length != node.m_Nodes.length) return false;
|
||||
for (int i = 0; i < this.m_Nodes.length; i++) {
|
||||
if (!this.m_Nodes[i].equals(node.m_Nodes[i])) return false;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** This method will be used to identify the node in the GPAreaEditor
|
||||
* @return The name.
|
||||
*/
|
||||
|
@ -28,24 +28,6 @@ public class GPNodeDiv extends AbstractGPNode implements java.io.Serializable {
|
||||
for (int i = 0; i < node.m_Nodes.length; i++) this.m_Nodes[i] = (AbstractGPNode) node.m_Nodes[i].clone();
|
||||
}
|
||||
|
||||
/** This method allows you to determine wehter or not two subtrees
|
||||
* are actually the same.
|
||||
* @param obj The other subtree.
|
||||
* @return boolean if equal true else false.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof GPNodeDiv) {
|
||||
GPNodeDiv node = (GPNodeDiv)obj;
|
||||
if (this.m_Nodes.length != node.m_Nodes.length) return false;
|
||||
for (int i = 0; i < this.m_Nodes.length; i++) {
|
||||
if (!this.m_Nodes[i].equals(node.m_Nodes[i])) return false;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** This method will be used to identify the node in the GPAreaEditor
|
||||
* @return The name.
|
||||
*/
|
||||
|
@ -20,24 +20,6 @@ public class GPNodeExp extends AbstractGPNode implements java.io.Serializable {
|
||||
for (int i = 0; i < node.m_Nodes.length; i++) this.m_Nodes[i] = (AbstractGPNode) node.m_Nodes[i].clone();
|
||||
}
|
||||
|
||||
/** This method allows you to determine wehter or not two subtrees
|
||||
* are actually the same.
|
||||
* @param obj The other subtree.
|
||||
* @return boolean if equal true else false.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof GPNodeExp) {
|
||||
GPNodeExp node = (GPNodeExp)obj;
|
||||
if (this.m_Nodes.length != node.m_Nodes.length) return false;
|
||||
for (int i = 0; i < this.m_Nodes.length; i++) {
|
||||
if (!this.m_Nodes[i].equals(node.m_Nodes[i])) return false;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** This method will be used to identify the node in the GPAreaEditor
|
||||
* @return The name.
|
||||
*/
|
||||
|
@ -21,24 +21,6 @@ public class GPNodeFlowExec2 extends AbstractGPNode implements java.io.Serializa
|
||||
for (int i = 0; i < node.m_Nodes.length; i++) this.m_Nodes[i] = (AbstractGPNode) node.m_Nodes[i].clone();
|
||||
}
|
||||
|
||||
/** This method allows you to determine wehter or not two subtrees
|
||||
* are actually the same.
|
||||
* @param obj The other subtree.
|
||||
* @return boolean if equal true else false.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof GPNodeFlowExec2) {
|
||||
GPNodeFlowExec2 node = (GPNodeFlowExec2)obj;
|
||||
if (this.m_Nodes.length != node.m_Nodes.length) return false;
|
||||
for (int i = 0; i < this.m_Nodes.length; i++) {
|
||||
if (!this.m_Nodes[i].equals(node.m_Nodes[i])) return false;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** This method will be used to identify the node in the GPAreaEditor
|
||||
* @return The name.
|
||||
*/
|
||||
|
@ -21,24 +21,6 @@ public class GPNodeFlowExec3 extends AbstractGPNode implements java.io.Serializa
|
||||
for (int i = 0; i < node.m_Nodes.length; i++) this.m_Nodes[i] = (AbstractGPNode) node.m_Nodes[i].clone();
|
||||
}
|
||||
|
||||
/** This method allows you to determine wehter or not two subtrees
|
||||
* are actually the same.
|
||||
* @param obj The other subtree.
|
||||
* @return boolean if equal true else false.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof GPNodeFlowExec3) {
|
||||
GPNodeFlowExec3 node = (GPNodeFlowExec3)obj;
|
||||
if (this.m_Nodes.length != node.m_Nodes.length) return false;
|
||||
for (int i = 0; i < this.m_Nodes.length; i++) {
|
||||
if (!this.m_Nodes[i].equals(node.m_Nodes[i])) return false;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** This method will be used to identify the node in the GPAreaEditor
|
||||
* @return The name.
|
||||
*/
|
||||
|
@ -40,11 +40,7 @@ public class GPNodeInput extends AbstractGPNode implements java.io.Serializable
|
||||
m_Identifier=str;
|
||||
}
|
||||
|
||||
/** This method allows you to determine wehter or not two subtrees
|
||||
* are actually the same.
|
||||
* @param obj The other subtree.
|
||||
* @return boolean if equal true else false.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof GPNodeInput) {
|
||||
GPNodeInput node = (GPNodeInput)obj;
|
||||
|
@ -21,24 +21,6 @@ public class GPNodeMult extends AbstractGPNode implements java.io.Serializable {
|
||||
for (int i = 0; i < node.m_Nodes.length; i++) this.m_Nodes[i] = (AbstractGPNode) node.m_Nodes[i].clone();
|
||||
}
|
||||
|
||||
/** This method allows you to determine wehter or not two subtrees
|
||||
* are actually the same.
|
||||
* @param obj The other subtree.
|
||||
* @return boolean if equal true else false.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof GPNodeMult) {
|
||||
GPNodeMult node = (GPNodeMult)obj;
|
||||
if (this.m_Nodes.length != node.m_Nodes.length) return false;
|
||||
for (int i = 0; i < this.m_Nodes.length; i++) {
|
||||
if (!this.m_Nodes[i].equals(node.m_Nodes[i])) return false;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** This method will be used to identify the node in the GPAreaEditor
|
||||
* @return The name.
|
||||
*/
|
||||
|
@ -21,24 +21,6 @@ public class GPNodeNeg extends AbstractGPNode implements java.io.Serializable {
|
||||
for (int i = 0; i < node.m_Nodes.length; i++) this.m_Nodes[i] = (AbstractGPNode) node.m_Nodes[i].clone();
|
||||
}
|
||||
|
||||
/** This method allows you to determine wehter or not two subtrees
|
||||
* are actually the same.
|
||||
* @param obj The other subtree.
|
||||
* @return boolean if equal true else false.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof GPNodeNeg) {
|
||||
GPNodeNeg node = (GPNodeNeg)obj;
|
||||
if (this.m_Nodes.length != node.m_Nodes.length) return false;
|
||||
for (int i = 0; i < this.m_Nodes.length; i++) {
|
||||
if (!this.m_Nodes[i].equals(node.m_Nodes[i])) return false;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** This method will be used to identify the node in the GPAreaEditor
|
||||
* @return The name.
|
||||
*/
|
||||
|
@ -35,11 +35,7 @@ public class GPNodeOutput extends AbstractGPNode implements java.io.Serializable
|
||||
for (int i = 0; i < node.m_Nodes.length; i++) this.m_Nodes[i] = (AbstractGPNode) node.m_Nodes[i].clone();
|
||||
}
|
||||
|
||||
/** This method allows you to determine wehter or not two subtrees
|
||||
* are actually the same.
|
||||
* @param obj The other subtree.
|
||||
* @return boolean if equal true else false.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof GPNodeOutput) {
|
||||
GPNodeOutput node = (GPNodeOutput)obj;
|
||||
|
@ -20,24 +20,6 @@ public class GPNodePow2 extends AbstractGPNode implements java.io.Serializable {
|
||||
for (int i = 0; i < node.m_Nodes.length; i++) this.m_Nodes[i] = (AbstractGPNode) node.m_Nodes[i].clone();
|
||||
}
|
||||
|
||||
/** This method allows you to determine wehter or not two subtrees
|
||||
* are actually the same.
|
||||
* @param obj The other subtree.
|
||||
* @return boolean if equal true else false.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof GPNodePow2) {
|
||||
GPNodePow2 node = (GPNodePow2)obj;
|
||||
if (this.m_Nodes.length != node.m_Nodes.length) return false;
|
||||
for (int i = 0; i < this.m_Nodes.length; i++) {
|
||||
if (!this.m_Nodes[i].equals(node.m_Nodes[i])) return false;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** This method will be used to identify the node in the GPAreaEditor
|
||||
* @return The name.
|
||||
*/
|
||||
|
@ -20,24 +20,6 @@ public class GPNodePow3 extends AbstractGPNode implements java.io.Serializable {
|
||||
for (int i = 0; i < node.m_Nodes.length; i++) this.m_Nodes[i] = (AbstractGPNode) node.m_Nodes[i].clone();
|
||||
}
|
||||
|
||||
/** This method allows you to determine wehter or not two subtrees
|
||||
* are actually the same.
|
||||
* @param obj The other subtree.
|
||||
* @return boolean if equal true else false.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof GPNodePow3) {
|
||||
GPNodePow3 node = (GPNodePow3)obj;
|
||||
if (this.m_Nodes.length != node.m_Nodes.length) return false;
|
||||
for (int i = 0; i < this.m_Nodes.length; i++) {
|
||||
if (!this.m_Nodes[i].equals(node.m_Nodes[i])) return false;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** This method will be used to identify the node in the GPAreaEditor
|
||||
* @return The name.
|
||||
*/
|
||||
|
@ -20,24 +20,6 @@ public class GPNodeProd extends AbstractGPNode implements java.io.Serializable {
|
||||
for (int i = 0; i < node.m_Nodes.length; i++) this.m_Nodes[i] = (AbstractGPNode) node.m_Nodes[i].clone();
|
||||
}
|
||||
|
||||
/** This method allows you to determine wehter or not two subtrees
|
||||
* are actually the same.
|
||||
* @param obj The other subtree.
|
||||
* @return boolean if equal true else false.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof GPNodeProd) {
|
||||
GPNodeProd node = (GPNodeProd)obj;
|
||||
if (this.m_Nodes.length != node.m_Nodes.length) return false;
|
||||
for (int i = 0; i < this.m_Nodes.length; i++) {
|
||||
if (!this.m_Nodes[i].equals(node.m_Nodes[i])) return false;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** This method will be used to identify the node in the GPAreaEditor
|
||||
* @return The name.
|
||||
*/
|
||||
|
@ -20,24 +20,6 @@ public class GPNodeSin extends AbstractGPNode implements java.io.Serializable {
|
||||
for (int i = 0; i < node.m_Nodes.length; i++) this.m_Nodes[i] = (AbstractGPNode) node.m_Nodes[i].clone();
|
||||
}
|
||||
|
||||
/** This method allows you to determine wehter or not two subtrees
|
||||
* are actually the same.
|
||||
* @param obj The other subtree.
|
||||
* @return boolean if equal true else false.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof GPNodeSin) {
|
||||
GPNodeSin node = (GPNodeSin)obj;
|
||||
if (this.m_Nodes.length != node.m_Nodes.length) return false;
|
||||
for (int i = 0; i < this.m_Nodes.length; i++) {
|
||||
if (!this.m_Nodes[i].equals(node.m_Nodes[i])) return false;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** This method will be used to identify the node in the GPAreaEditor
|
||||
* @return The name.
|
||||
*/
|
||||
|
@ -21,24 +21,6 @@ public class GPNodeSqrt extends AbstractGPNode implements java.io.Serializable {
|
||||
for (int i = 0; i < node.m_Nodes.length; i++) this.m_Nodes[i] = (AbstractGPNode) node.m_Nodes[i].clone();
|
||||
}
|
||||
|
||||
/** This method allows you to determine wehter or not two subtrees
|
||||
* are actually the same.
|
||||
* @param obj The other subtree.
|
||||
* @return boolean if equal true else false.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof GPNodeSqrt) {
|
||||
GPNodeSqrt node = (GPNodeSqrt)obj;
|
||||
if (this.m_Nodes.length != node.m_Nodes.length) return false;
|
||||
for (int i = 0; i < this.m_Nodes.length; i++) {
|
||||
if (!this.m_Nodes[i].equals(node.m_Nodes[i])) return false;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** This method will be used to identify the node in the GPAreaEditor
|
||||
* @return The name.
|
||||
*/
|
||||
|
@ -21,24 +21,6 @@ public class GPNodeSub extends AbstractGPNode implements java.io.Serializable {
|
||||
for (int i = 0; i < node.m_Nodes.length; i++) this.m_Nodes[i] = (AbstractGPNode) node.m_Nodes[i].clone();
|
||||
}
|
||||
|
||||
/** This method allows you to determine wehter or not two subtrees
|
||||
* are actually the same.
|
||||
* @param obj The other subtree.
|
||||
* @return boolean if equal true else false.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof GPNodeSub) {
|
||||
GPNodeSub node = (GPNodeSub)obj;
|
||||
if (this.m_Nodes.length != node.m_Nodes.length) return false;
|
||||
for (int i = 0; i < this.m_Nodes.length; i++) {
|
||||
if (!this.m_Nodes[i].equals(node.m_Nodes[i])) return false;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** This method will be used to identify the node in the GPAreaEditor
|
||||
* @return The name.
|
||||
*/
|
||||
|
@ -20,24 +20,6 @@ public class GPNodeSum extends AbstractGPNode implements java.io.Serializable {
|
||||
for (int i = 0; i < node.m_Nodes.length; i++) this.m_Nodes[i] = (AbstractGPNode) node.m_Nodes[i].clone();
|
||||
}
|
||||
|
||||
/** This method allows you to determine wehter or not two subtrees
|
||||
* are actually the same.
|
||||
* @param obj The other subtree.
|
||||
* @return boolean if equal true else false.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof GPNodeSum) {
|
||||
GPNodeSum node = (GPNodeSum)obj;
|
||||
if (this.m_Nodes.length != node.m_Nodes.length) return false;
|
||||
for (int i = 0; i < this.m_Nodes.length; i++) {
|
||||
if (!this.m_Nodes[i].equals(node.m_Nodes[i])) return false;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** This method will be used to identify the node in the GPAreaEditor
|
||||
* @return The name.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user