#ifndef POPULATION_H
#define POPULATION_H

#include "../rand/randomc.h"
#include "individual.h"
#include "population_block.h"
#include "fresh_list_block.h"

#define DEFAULT_INDEX -1

class population {
  int size;
  int fresh;
  int max_size;
  individual **ind_tab;
  fresh_list_block *fresh_lst;
public:
  int *random_tuple(int *, int, int, RANDOM_GENERATOR *);
  int *quick_sort(int *, int);

  population(int);
  population(population *);
  ~population();

  int get_size() { return size; }
  int get_fresh() { return fresh; }
  int get_maximum_size() { return max_size; }

  bool is_empty() { return (size == 0); }
  bool is_full() { return (size == max_size); }
  bool fresh_left() { return (fresh > 0); }

  void refill(char, int, float, float, RANDOM_GENERATOR *);
  void refresh();
  void add_individual(individual *);
  individual *pick_individual(int);
  individual *pick_first_fresh();
  population_block *get_best(int);
  population_block *pick_random_tuple(int, RANDOM_GENERATOR *);

  float get_total_fitness();
  float get_average_fitness();
  float get_diversity(float&);
  void print();
};

#endif /* POPULATION_H */

