lio.population
Class VariablePopulation

java.lang.Object
  extended by lio.population.Population
      extended by lio.population.VariablePopulation

public class VariablePopulation
extends Population


Field Summary
 
Fields inherited from class lio.population.Population
size
 
Constructor Summary
VariablePopulation()
          Constructor
VariablePopulation(Individual[] individuals)
          Constructor Encapsulates an array of individuals into a VariablePopulation.
VariablePopulation(int pNumPositions)
          Constructor The parameter pNumPositions is provided for efficiency and must be the maximum size estimated.
 
Method Summary
 void addElement(Individual individual)
          Append the specified individual to the end of the population
 void compress()
          Deletes all empty positions of the population.
 Individual elementAt(int position)
          Returns a reference to the individual in the given position.
 int getNumPositions()
           
 Individual[] individuals()
          Returns an array containing all individuals, but not empty spaces.
 void remove(int position)
          Removes an element of the population given its position.
 void removeElementAt(int position, boolean keepPosition)
          Removes an element of the population given its position.
 void setElementAt(int position, Individual individual)
          Replaces the element at given position.
 
Methods inherited from class lio.population.Population
copyElementAt, size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VariablePopulation

public VariablePopulation()
Constructor


VariablePopulation

public VariablePopulation(int pNumPositions)
Constructor The parameter pNumPositions is provided for efficiency and must be the maximum size estimated.

Parameters:
pNumPositions - Maximum estimated size of the Array containing the individuals.

VariablePopulation

public VariablePopulation(Individual[] individuals)
Constructor Encapsulates an array of individuals into a VariablePopulation.

Parameters:
individuals - Array of individuals that will form the population.
Method Detail

elementAt

public Individual elementAt(int position)
Returns a reference to the individual in the given position.

Specified by:
elementAt in class Population
Parameters:
position - Individual that is referenced.
Returns:
The individual that occupies position position.

removeElementAt

public void removeElementAt(int position,
                            boolean keepPosition)
Removes an element of the population given its position.

Parameters:
position - Position of the element to remove.
keepPosition - Tells whether indexes in the population must be kept

remove

public void remove(int position)
Removes an element of the population given its position.

Parameters:
position - Position of the element to remove.

addElement

public void addElement(Individual individual)
Append the specified individual to the end of the population

Parameters:
individual - new individual to be added

setElementAt

public void setElementAt(int position,
                         Individual individual)
Replaces the element at given position.

Specified by:
setElementAt in class Population
Parameters:
position - Position where the individual will be placed.
individual - Individual to be stored at the population.

individuals

public Individual[] individuals()
Returns an array containing all individuals, but not empty spaces.

Specified by:
individuals in class Population
Returns:
Individuals of the population.

compress

public void compress()
Deletes all empty positions of the population.


getNumPositions

public int getNumPositions()
Returns:
The number of positions available on the population