com.groovyj.jgprog.functions
Class Add

java.lang.Object
  |
  +--com.groovyj.jgprog.Function
        |
        +--com.groovyj.jgprog.functions.Add
All Implemented Interfaces:
java.io.Serializable

public class Add
extends Function
implements java.io.Serializable

The addition function. Allowed to be of type int, long, float, or double. Its two children are the addends, and must be of the same type as this node.

Copyright (c) 2000 Robert Baruch. This code is released under the GNU General Public License (GPL).

Version:
$Id: Add.java,v 1.1 2000/10/12 15:19:39 groovyjava Exp $
Author:
Robert Baruch (jgprog@sourceforge.net)
See Also:
Serialized Form

Inner Class Summary
static interface Add.Compatible
           
 
Fields inherited from class com.groovyj.jgprog.Function
arity, individual, returnType
 
Constructor Summary
Add(Type type)
          Creates an addition node of the given type
 
Method Summary
 double execute_double(Chromosome c, int n)
          Executes this node as a double.
 float execute_float(Chromosome c, int n)
          Executes this node as a float.
 int execute_int(Chromosome c, int n)
          Executes this node as an integer.
 long execute_long(Chromosome c, int n)
          Executes this node as a long.
 java.lang.Object execute_object(Chromosome c, int n)
          Executes this node as an object.
 Type getChildType(int i)
          Gets the type of node allowed form the given child number.
 java.lang.String getName()
          Gets the name of this node.
 
Methods inherited from class com.groovyj.jgprog.Function
execute_boolean, execute_void, execute, getArity, getReturnType, setIndividual, setReturnType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Add

public Add(Type type)
Creates an addition node of the given type
Parameters:
type - the type of the node
Since:
1.0
Method Detail

getName

public java.lang.String getName()
Description copied from class: Function
Gets the name of this node. Must be overridden in subclasses.
Overrides:
getName in class Function
Following copied from class: com.groovyj.jgprog.Function
Returns:
the name of this node.

execute_int

public int execute_int(Chromosome c,
                       int n)
Description copied from class: Function
Executes this node as an integer.
Overrides:
execute_int in class Function
Following copied from class: com.groovyj.jgprog.Function
Returns:
the integer return value of this node
Throws:
UnsupportedOperationException - if the type of this node is not integer

execute_long

public long execute_long(Chromosome c,
                         int n)
Description copied from class: Function
Executes this node as a long.
Overrides:
execute_long in class Function
Following copied from class: com.groovyj.jgprog.Function
Returns:
the long return value of this node
Throws:
UnsupportedOperationException - if the type of this node is not long

execute_float

public float execute_float(Chromosome c,
                           int n)
Description copied from class: Function
Executes this node as a float.
Overrides:
execute_float in class Function
Following copied from class: com.groovyj.jgprog.Function
Returns:
the float return value of this node
Throws:
UnsupportedOperationException - if the type of this node is not float

execute_double

public double execute_double(Chromosome c,
                             int n)
Description copied from class: Function
Executes this node as a double.
Overrides:
execute_double in class Function
Following copied from class: com.groovyj.jgprog.Function
Returns:
the double return value of this node
Throws:
UnsupportedOperationException - if the type of this node is not double

execute_object

public java.lang.Object execute_object(Chromosome c,
                                       int n)
Description copied from class: Function
Executes this node as an object.
Overrides:
execute_object in class Function
Following copied from class: com.groovyj.jgprog.Function
Returns:
the object return value of this node
Throws:
UnsupportedOperationException - if the type of this node is not object

getChildType

public Type getChildType(int i)
Description copied from class: Function
Gets the type of node allowed form the given child number. Must be overridden in subclasses.
Overrides:
getChildType in class Function
Following copied from class: com.groovyj.jgprog.Function
Parameters:
i - the child number
Returns:
the type of node allowed for that child