net.openai.ai.ga.population
Class PopulationArray

java.lang.Object
  |
  +--net.openai.ai.ga.population.PopulationArray
All Implemented Interfaces:
java.io.Serializable

public class PopulationArray
extends java.lang.Object
implements java.io.Serializable

The PopulationArray is the equilivant of an array of Population elements. This offers the advantage of dynamicism in size and in adding and removing elements from the collection.

Since:
JDK1.3
Version:
%I%, %G%
Author:
Jared Grubb
See Also:
Serialized Form

Field Summary
protected  java.util.Collection pops
          The Collection that holds all the Populations
 
Constructor Summary
PopulationArray()
          Creates a PopulationArray using an ArrayList
PopulationArray(java.util.Collection initialCollection)
          Creates a PopulationArray with a given initial Collection
PopulationArray(PopulationArray toClone)
          Creates a shallow clone of the passed PopulationArray.
 
Method Summary
 void addPopulation(Population toAdd)
          Adds a Population to this PopulationArray.
 void addPopulations(PopulationArray toAdd)
          Adds all the Populations in the given PopulationArray.
 void cleanse()
          Removes non-Population objects from the Collection
 Population[] getPopulationArray()
          Returns a Population[] array representing all the Populations in this population array.
 java.util.Iterator getPopulationIterator()
          Returns an Iterator to be used to iterate through all the Populations in this PopulationArray.
 java.util.Collection getPopulations()
          Returns a Collection representing the internal representation of the PopulationArray
 int getSize()
          Returns the number of Populations in this PopulationArrays.
 void removeAllSameAs(Population toRemove)
          Removes all instances of Population from this PopulationArray.
 boolean removePopulation(Population toRemove)
          Removes a Population from this PopulationArray .
 void removePopulations(PopulationArray toRemove)
          Removes a group of Populations from this PopulationArray.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

pops

protected java.util.Collection pops
The Collection that holds all the Populations

Constructor Detail

PopulationArray

public PopulationArray()
Creates a PopulationArray using an ArrayList


PopulationArray

public PopulationArray(java.util.Collection initialCollection)
Creates a PopulationArray with a given initial Collection

Parameters:
initialCollection - the Collection to initialize to

PopulationArray

public PopulationArray(PopulationArray toClone)
Creates a shallow clone of the passed PopulationArray. This is not a complete clone, in which each of the Population s would also be cloned; this instead creates a copy of the list of Populations to which additions and removals do not affect the original population.

Method Detail

addPopulation

public void addPopulation(Population toAdd)
Adds a Population to this PopulationArray. Does nothing when given null.

Parameters:
toAdd - the Population to add

addPopulations

public void addPopulations(PopulationArray toAdd)
Adds all the Populations in the given PopulationArray. Does nothing on null or an empty PopulationArray.

Parameters:
toAdd - the PopulationArray to add

removePopulation

public boolean removePopulation(Population toRemove)
Removes a Population from this PopulationArray . Returns whether the removal was successful or not. Returns true when given a null.

Parameters:
toRemove - the Cell to remove
Returns:
true on success;
false otherwise

removePopulations

public void removePopulations(PopulationArray toRemove)
Removes a group of Populations from this PopulationArray. Does not indicate whether the removal was successful or not. Does nothing when given a null or an empty Population. Does not throw ArrayIndexOutOfBoundsException.

Parameters:
toRemove - the PopulationArray to remove

removeAllSameAs

public void removeAllSameAs(Population toRemove)
Removes all instances of Population from this PopulationArray. Does not indicate whether any removal took place. Does nothing when given a null or a non-existant Population.

Parameters:
toRemove - the PopulationArray to remove

getPopulationArray

public Population[] getPopulationArray()
Returns a Population[] array representing all the Populations in this population array. Returns an empty array when empty.

Returns:
Population[] of all Populations

getPopulations

public java.util.Collection getPopulations()
Returns a Collection representing the internal representation of the PopulationArray

Returns:
Population[] of all Populations

getSize

public int getSize()
Returns the number of Populations in this PopulationArrays.

Returns:
the number of Populations

getPopulationIterator

public java.util.Iterator getPopulationIterator()
Returns an Iterator to be used to iterate through all the Populations in this PopulationArray.

Returns:
an Iterator on the Population collection

cleanse

public void cleanse()
Removes non-Population objects from the Collection


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright - 2001 OpenAI Labs. All Rights Reserved.