public class Population<G extends Gene<?,G>,C extends Comparable<? super C>> extends Object implements List<Phenotype<G,C>>, Copyable<Population<G,C>>, RandomAccess, Serializable
This class is not synchronized. If multiple threads access
a Population
concurrently, and at least one of the threads modifies
it, it must be synchronized externally.
Constructor and Description |
---|
Population()
Creating a new
Population . |
Population(Collection<Phenotype<G,C>> population)
Constructs a population containing the elements of the specified collection,
in the order they are returned by the collection's iterator.
|
Population(int size)
Creating a new
Population with the pre-allocated population
size. |
Modifier and Type | Method and Description |
---|---|
void |
add(int index,
Phenotype<G,C> phenotype)
Add
Phenotype to the Population . |
boolean |
add(Phenotype<G,C> phenotype)
Add
Phenotype to the Population . |
boolean |
addAll(Collection<? extends Phenotype<G,C>> c) |
boolean |
addAll(int index,
Collection<? extends Phenotype<G,C>> c) |
void |
clear() |
boolean |
contains(Object o) |
boolean |
containsAll(Collection<?> c) |
Population<G,C> |
copy()
Return a new copy of type
T . |
boolean |
equals(Object obj) |
Population<G,C> |
fill(Factory<Phenotype<G,C>> factory,
int count)
Fills the population with individuals created by the given factory.
|
Phenotype<G,C> |
get(int index) |
int |
hashCode() |
int |
indexOf(Object o) |
boolean |
isEmpty() |
Iterator<Phenotype<G,C>> |
iterator() |
int |
lastIndexOf(Object o) |
ListIterator<Phenotype<G,C>> |
listIterator() |
ListIterator<Phenotype<G,C>> |
listIterator(int index) |
void |
populationSort()
Sorting the phenotypes in this population according to its fitness
value in descending order.
|
Phenotype<G,C> |
remove(int index) |
boolean |
remove(Object o) |
void |
remove(Phenotype<G,C> phenotype) |
boolean |
removeAll(Collection<?> c) |
boolean |
retainAll(Collection<?> c) |
void |
reverse()
Reverse the order of the population.
|
Phenotype<G,C> |
set(int index,
Phenotype<G,C> pt) |
int |
size() |
void |
sortWith(Comparator<? super C> comparator)
Sort this population according the order defined by the given
comparator . |
Stream<Phenotype<G,C>> |
stream() |
List<Phenotype<G,C>> |
subList(int fromIndex,
int toIndex) |
Object[] |
toArray() |
<A> A[] |
toArray(A[] a) |
static <G extends Gene<?,G>,C extends Comparable<? super C>> |
toPopulation()
Returns a
Collector that accumulates the input elements into a
new Population . |
String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
replaceAll, sort, spliterator
parallelStream, removeIf
public Population(Collection<Phenotype<G,C>> population)
population
- the collection whose elements are to be placed into
this list.NullPointerException
- if the specified population is null
.public Population(int size)
Population
with the pre-allocated population
size.size
- Pre-allocated population size.IllegalArgumentException
- if the specified initial capacity is
negativepublic Population()
Population
.public Population<G,C> fill(Factory<Phenotype<G,C>> factory, int count)
factory
- the Phenotype
factory.count
- the number of individuals to add to this population.public boolean add(Phenotype<G,C> phenotype)
Phenotype
to the Population
.add
in interface Collection<Phenotype<G extends Gene<?,G>,C extends Comparable<? super C>>>
add
in interface List<Phenotype<G extends Gene<?,G>,C extends Comparable<? super C>>>
phenotype
- Phenotype
to be add.NullPointerException
- if the given phenotype
is
null
.public void add(int index, Phenotype<G,C> phenotype)
Phenotype
to the Population
.add
in interface List<Phenotype<G extends Gene<?,G>,C extends Comparable<? super C>>>
index
- Index of thephenotype
- Phenotype
to be add.NullPointerException
- if the given phenotype
is
null
.public boolean addAll(Collection<? extends Phenotype<G,C>> c)
public boolean addAll(int index, Collection<? extends Phenotype<G,C>> c)
public Stream<Phenotype<G,C>> stream()
stream
in interface Collection<Phenotype<G extends Gene<?,G>,C extends Comparable<? super C>>>
public boolean removeAll(Collection<?> c)
public void clear()
public void populationSort()
public void sortWith(Comparator<? super C> comparator)
comparator
.comparator
- the comparator which defines the sorting order.NullPointerException
- if the comparator
is
null
.public void reverse()
public Iterator<Phenotype<G,C>> iterator()
iterator
in interface Iterable<Phenotype<G extends Gene<?,G>,C extends Comparable<? super C>>>
iterator
in interface Collection<Phenotype<G extends Gene<?,G>,C extends Comparable<? super C>>>
iterator
in interface List<Phenotype<G extends Gene<?,G>,C extends Comparable<? super C>>>
public ListIterator<Phenotype<G,C>> listIterator()
listIterator
in interface List<Phenotype<G extends Gene<?,G>,C extends Comparable<? super C>>>
public ListIterator<Phenotype<G,C>> listIterator(int index)
listIterator
in interface List<Phenotype<G extends Gene<?,G>,C extends Comparable<? super C>>>
public int size()
public boolean isEmpty()
public boolean containsAll(Collection<?> c)
containsAll
in interface Collection<Phenotype<G extends Gene<?,G>,C extends Comparable<? super C>>>
containsAll
in interface List<Phenotype<G extends Gene<?,G>,C extends Comparable<? super C>>>
public int lastIndexOf(Object o)
lastIndexOf
in interface List<Phenotype<G extends Gene<?,G>,C extends Comparable<? super C>>>
public boolean retainAll(Collection<?> c)
public <A> A[] toArray(A[] a)
public Population<G,C> copy()
Copyable
T
.copy
in interface Copyable<Population<G extends Gene<?,G>,C extends Comparable<? super C>>>
T
.public int hashCode()
public static <G extends Gene<?,G>,C extends Comparable<? super C>> Collector<Phenotype<G,C>,?,Population<G,C>> toPopulation()
Collector
that accumulates the input elements into a
new Population
.G
- the gene typeC
- the fitness result typeCollector
which collects all the input elements into a
Population
, in encounter order© 2007-2014 Franz Wilhelmstötter (2014-12-28 10:45)