|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--net.openai.ai.ga.population.PopulationArray
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.
Field Summary | |
protected java.util.Collection |
pops
The Collection that holds all the Population s |
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 Population s in the given
PopulationArray . |
void |
cleanse()
Removes non- Population objects from the
Collection |
Population[] |
getPopulationArray()
Returns a Population[] array representing all the
Population s in this population array. |
java.util.Iterator |
getPopulationIterator()
Returns an Iterator to be used to iterate through all the
Population s in this PopulationArray . |
java.util.Collection |
getPopulations()
Returns a Collection representing the internal
representation of the PopulationArray |
int |
getSize()
Returns the number of Population s 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 Population s 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 |
protected java.util.Collection pops
Collection
that holds all the Population
s
Constructor Detail |
public PopulationArray()
PopulationArray
using an ArrayList
public PopulationArray(java.util.Collection initialCollection)
PopulationArray
with a given initial
Collection
initialCollection
- the Collection
to initialize topublic PopulationArray(PopulationArray toClone)
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 Population
s to which additions and removals
do not affect the original population.
Method Detail |
public void addPopulation(Population toAdd)
Population
to this PopulationArray
.
Does nothing when given null
.
toAdd
- the Population
to addpublic void addPopulations(PopulationArray toAdd)
Population
s in the given
PopulationArray
. Does nothing on null
or an
empty PopulationArray
.
toAdd
- the PopulationArray
to addpublic boolean removePopulation(Population toRemove)
Population
from this PopulationArray
. Returns whether the removal was successful or not. Returns
true
when given a null
.
toRemove
- the Cell
to remove
true
on success;false
otherwisepublic void removePopulations(PopulationArray toRemove)
Population
s 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.
toRemove
- the PopulationArray
to removepublic void removeAllSameAs(Population toRemove)
Population
from this
PopulationArray
. Does not indicate whether any removal took
place. Does nothing when given a null
or a non-existant
Population
.
toRemove
- the PopulationArray
to removepublic Population[] getPopulationArray()
Population[]
array representing all the
Population
s in this population array. Returns an empty
array when empty.
Population[]
of all Population
spublic java.util.Collection getPopulations()
Collection
representing the internal
representation of the PopulationArray
Population[]
of all Population
spublic int getSize()
Population
s in this
PopulationArrays
.
Population
spublic java.util.Iterator getPopulationIterator()
Population
s in this PopulationArray
.
Iterator
on the Population
collectionpublic void cleanse()
Population
objects from the
Collection
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |