sn_population.[ch]: Add the sn_population object.
[sort-networks.git] / src / sn_population.h
1 #ifndef SN_POPULATION_H
2 #define SN_POPULATION_H 1
3
4 #include <stdint.h>
5 #include "sn_network.h"
6
7 /*
8  * sn_population_t
9  *
10  * Opaque data type for the population.
11  */
12 struct sn_population_s;
13 typedef struct sn_population_s sn_population_t;
14
15 sn_population_t *sn_population_create (uint32_t size);
16 void sn_population_destroy (sn_population_t *p);
17
18 /*
19  * push
20  *
21  * Puts a new network into the population. The network is _copied_ and may be
22  * modified by the caller after inserting the network. This won'thave an effect
23  * on the copy in the population, though. Of course, the caller must free his
24  * own copy himself!
25  */
26 int sn_population_push (sn_population_t *p, sn_network_t *n);
27
28 /*
29  * pop
30  *
31  * Returns a _copy_ of an individuum in the population. The network is NOT
32  * removed from the population by this operation! The caller must free this
33  * copy himself. Returns NULL upon failure.
34  */
35 sn_network_t *sn_population_pop (sn_population_t *p);
36
37 sn_network_t *sn_population_best (sn_population_t *p);
38
39 #endif /* SN_POPULATION_H */