e.g., an allele of a haploid individual was represented by an integer, 0 or 1.
Examples:
Convinient to have the ``state'' data of each subpopulation together.
Relevant data to characterize a single individual:
Alleles at each locus
Phenotypes
struct coord {
int x;
int y;
};
Two integers are grouped together to make this structure.
struct coord c1, c2;
struct coord {
int x;
int y;
} c1, c2;
c1.x = 10; c1.y = 20; c2.x = c1.x; c2.y = c1.y;
Each variable has a container for each member. You can access the value by varName.memberName.
c2 = c1;
struct line {
struct coord begin;
struct coord end;
};
struct line l1;
l1.begin.x = 0;
l1.begin.y = 0;
l1.end.x = 10;
l1.end.y = 10;
struct genotype {
int locus1[2];
int locus2[2];
} g1;
g1.locus1[0] = g1.locus1[1] = 1;
struct myArray {
double *data;
int size;
} arr;
arr.data = (double *) calloc(20, sizeof(double));
arr.size = 20;
CntLessThan(arr, 10.0);
int CntLessThan(struct myArray thisArr, double x) {
int i, cnt = 0;
for (i = 0; i < thisArr.size; i++) {
cnt += (thisArr.data[i] < x);
}
}
struct myArray *aPtr; aPtr = & arr; (*aPtr).data[0] = (*aPtr).data[1] + (*aPtr).data[2];Don't forget the parenthese here.
tmp = aPtr->size - 1; tmp = (*aPtr).size - 1;These two statements are exactly same.
struct genotypes pop[100];