Global: collectd → libsortnetwork
[sort-networks.git] / src / sn_population.h
1 /**
2  * libsortnetwork - src/sn_population.h
3  * Copyright (C) 2008-2010  Florian octo Forster
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License as published by the
7  * Free Software Foundation; only version 2 of the License is applicable.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
17  *
18  * Authors:
19  *   Florian octo Forster <ff at octo.it>
20  **/
21
22 #ifndef SN_POPULATION_H
23 #define SN_POPULATION_H 1
24
25 #include <stdint.h>
26 #include "sn_network.h"
27
28 /*
29  * sn_population_t
30  *
31  * Opaque data type for the population.
32  */
33 struct sn_population_s;
34 typedef struct sn_population_s sn_population_t;
35
36 sn_population_t *sn_population_create (uint32_t size);
37 void sn_population_destroy (sn_population_t *p);
38
39 /*
40  * push
41  *
42  * Puts a new network into the population. The network is _copied_ and may be
43  * modified by the caller after inserting the network. This won'thave an effect
44  * on the copy in the population, though. Of course, the caller must free his
45  * own copy himself!
46  */
47 int sn_population_push (sn_population_t *p, sn_network_t *n);
48
49 /*
50  * pop
51  *
52  * Returns a _copy_ of an individuum in the population. The network is NOT
53  * removed from the population by this operation! The caller must free this
54  * copy himself. Returns NULL upon failure.
55  */
56 sn_network_t *sn_population_pop (sn_population_t *p);
57
58 sn_network_t *sn_population_best (sn_population_t *p);
59 int sn_population_best_rating (sn_population_t *p);
60
61 #endif /* SN_POPULATION_H */