T
- public class GenericAlleleSet<T> extends java.lang.Object implements AlleleSet<T>
Set
.
At creation time, the aplhabet objects are not cloned so:
Note that this implementation is not synchronized. If multiple
threads access a GenericAlleleSet concurrently, and at least one of the threads modifies
the set, it must be synchronized externally or wrapped using the Collections.synchronizedSet(Set)
method.
Note that if values are modified externally, the allele set object also change according at that modification.
Some examples of code are provided below.
to build a generic allele set with the object value accesses synchronized.Set s = Collections.synchronizedSet(new HashSet(...)); GenericAlleleSet geneticAlleleSet = new GenericAlleleSet(s);
to build a generic allele set with the boolean values as allele object values.GenericAlleleSet generic alleleSet = new GenericAlleleSet(true, false),
to build a generic allele set with the enum values.GenericAlleleSet generic alleleSet = new GenericAlleleSet(AnyJavaEnum.values()) );
ObjectChromosome
Constructor and Description |
---|
GenericAlleleSet(java.util.List<T> list)
Creates a new AlleleSet instance with the alphabet values contained by the specified list
|
GenericAlleleSet(java.util.Set<T> set)
Creates a new AlleleSet instance with the alphabet values contained by the specified set
|
GenericAlleleSet(T... values)
Creates a new AlleleSet instance with the alphabet values contained by the specified array
|
Modifier and Type | Method and Description |
---|---|
double |
difference(T a0,
T a1)
Provides the genetic difference between two alleles.
|
double[][] |
getDefaultDifferences()
Returns the default difference matrix as given by the difference of allele positions in the set.
|
T |
getElementAt(int pos)
Returns the allele at a given positition.
|
int |
getIndexOf(T a)
Returns the index of element a.
|
T |
getRandomValue()
Returns an allele randomly chosen.
|
void |
setDifferences(double[][] diff)
Sets the difference matrix between alleles.
|
int |
size()
Returns the number of alleles held by the allele set.
|
public GenericAlleleSet(java.util.Set<T> set)
set
- the set with the alphabet allele valuespublic GenericAlleleSet(T... values)
values
- the alphabet values arraypublic GenericAlleleSet(java.util.List<T> list)
list
- the alphabet values listpublic final T getElementAt(int pos)
getElementAt
in interface AlleleSet<T>
pos
- public final int getIndexOf(T a)
a
- - the allele to findpublic final T getRandomValue()
getRandomValue
in interface AlleleSet<T>
public final int size()
public void setDifferences(double[][] diff)
diff
- - the difference matrixpublic double[][] getDefaultDifferences()