gpsys.primitives
Class MemBoolean

java.lang.Object
  |
  +--gpsys.Primitive
        |
        +--gpsys.Terminal
              |
              +--gpsys.primitives.MemBoolean

public class MemBoolean
extends Terminal

	MEM_BOOLEAN MemBoolean
 
MemBoolean is a Terminal that implements indexed memory of Boolean type. The primitives MemGet and MemSet must be used to get and set any of the locations of the memory.

Version:
$Revision: 1.1 $, $Date: 2000/07/05 16:24:33 $
Author:
Adil Qureshi
Department of Computer Science,
University College London,
Gower St,
London WC1E 6BT,
UK.
See Also:
Type, Primitive, Terminal, gpsys.MemGet, gpsys.MemSet, Serialized Form

Field Summary
(package private)  boolean[] memory
          The array used to implement the memory.
 
Fields inherited from class gpsys.Primitive
type
 
Constructor Summary
MemBoolean(int size)
          Construct indexed memory of the specified size.
 
Method Summary
 java.lang.Object evaluateObject(Individual i)
          Evaluation of indexed memory just returns a reference to the memory.
 boolean get(int index)
          Gets the value of the specified memory location.
 Primitive instance()
          Creates a copy of this Terminal.
 void reset(int index)
          Sets the specified memory location to the default value (false).
 boolean set(int index, boolean value)
          Sets the specified memory location to the specified value.
 java.lang.String toString()
          Creates a String representing this Terminal.
 
Methods inherited from class gpsys.Terminal
evaluateBoolean, evaluateByte, evaluateChar, evaluateDouble, evaluateFloat, evaluateInt, evaluateLong, evaluateShort
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

memory

boolean[] memory
The array used to implement the memory.
Constructor Detail

MemBoolean

public MemBoolean(int size)
Construct indexed memory of the specified size.
Parameters:
size - The number memory locations needed.
Method Detail

evaluateObject

public final java.lang.Object evaluateObject(Individual i)
                                      throws EvaluationException
Evaluation of indexed memory just returns a reference to the memory. This reference can then be used as a parameter to MemGet or MemSet.
Parameters:
i - The individual being evaluated.
Returns:
A reference to this indexed memory object.
Throws:
EvaluationException - If there is an evaluation failure.
Overrides:
evaluateObject in class Terminal

reset

public final void reset(int index)
Sets the specified memory location to the default value (false).
Parameters:
index - The index of the memory location to be reset.

set

public final boolean set(int index,
                         boolean value)
Sets the specified memory location to the specified value.
Parameters:
index - The index of the memory location to be set.
value - The value to be assigned to the memory location.
Returns:
The value assigned to the specified memory location, if the index was valid (within range), and false otherwise.

get

public final boolean get(int index)
Gets the value of the specified memory location.
Parameters:
index - The index of the memory location to be read.
Returns:
The value of the specified memory location, if the index was valid (within range), and false otherwise.

instance

public final Primitive instance()
Creates a copy of this Terminal.
Returns:
Actaully a reference to the same Terminal since there is no change in instance variables required.
Overrides:
instance in class Primitive

toString

public java.lang.String toString()
Creates a String representing this Terminal.
Returns:
A String containing the name of this Terminal.
Overrides:
toString in class Primitive