From: Rafał Długołęcki Date: Fri, 1 May 2015 07:54:23 +0000 (+0200) Subject: Remove some not used namespace declarations. X-Git-Url: https://git.dlugolecki.net.pl/?a=commitdiff_plain;h=1e175fb658e55f4cc8b894fff288be22998e78af;p=genetic.git Remove some not used namespace declarations. --- diff --git a/include/chromosome.h b/include/chromosome.h index 378300a..bad2bdd 100644 --- a/include/chromosome.h +++ b/include/chromosome.h @@ -5,8 +5,6 @@ #include "gene.h" -using namespace std; - namespace genetic { /** * Chromosome of given Genes. diff --git a/include/condition/condition.h b/include/condition/condition.h index 2b17575..29ac133 100644 --- a/include/condition/condition.h +++ b/include/condition/condition.h @@ -4,8 +4,6 @@ #include "chromosome.h" #include "generation.h" -using namespace std; - namespace genetic { /** * Base Condition class. diff --git a/include/condition/generationLimitCondition.h b/include/condition/generationLimitCondition.h index e120a96..3101191 100644 --- a/include/condition/generationLimitCondition.h +++ b/include/condition/generationLimitCondition.h @@ -6,8 +6,6 @@ #include "condition.h" -using namespace std; - namespace genetic { /** * Condition class. It is used for checking if algorithm should stop after @@ -15,7 +13,6 @@ namespace genetic { */ template < typename _Chromosome> class GenerationLimitCondition : public Condition<_Chromosome> { - public: protected: /** * Variable indicating current generation diff --git a/include/crossover/crossover.h b/include/crossover/crossover.h index 395ac60..3befaed 100644 --- a/include/crossover/crossover.h +++ b/include/crossover/crossover.h @@ -1,6 +1,8 @@ #ifndef __CROSSOVER_CROSSOVER_H #define __CROSSOVER_CROSSOVER_H +#include + #include "chromosome.h" #include "generation.h" @@ -55,7 +57,7 @@ namespace genetic { // } // } - vector crossedChromosome; + std::vector crossedChromosome; for (unsigned int i = 0; i < chromosomeSize; i++) { if (i < splitPlace) { crossedChromosome.push_back(first[i].get()); diff --git a/include/generation.h b/include/generation.h index f460a7f..5dab37c 100644 --- a/include/generation.h +++ b/include/generation.h @@ -3,10 +3,8 @@ #include -#include -#include - -using namespace std; +#include "gene.h" +#include "chromosome.h" namespace genetic { /** @@ -18,7 +16,7 @@ namespace genetic { /** * Chromosomes in the given Generation */ - vector<_Chromosome> chromosomes; + std::vector<_Chromosome> chromosomes; template friend class Generation; public: diff --git a/include/generator/bitGenerator.h b/include/generator/bitGenerator.h index 8e92521..3b93420 100644 --- a/include/generator/bitGenerator.h +++ b/include/generator/bitGenerator.h @@ -52,7 +52,7 @@ namespace genetic { * @param generationSize Indicates size of the generation * @param chromosomeSize Indicates size of the chromosome */ - BitGenerator(unsigned int generationSize, unsigned int chromosomeSize) + BitGenerator(const unsigned int generationSize, const unsigned int chromosomeSize) : Generator<_Chromosome>(generationSize, chromosomeSize) { } }; diff --git a/include/generator/generator.h b/include/generator/generator.h index 64f2720..b9e5680 100644 --- a/include/generator/generator.h +++ b/include/generator/generator.h @@ -1,6 +1,7 @@ #ifndef __GENERATOR_GENERATOR_H #define __GENERATOR_GENERATOR_H +#include #include #include "../gene.h" @@ -25,12 +26,12 @@ namespace genetic { /** * Size of the generation to generate */ - unsigned int generationSize; + const unsigned int generationSize; /** * Size of the chromosome to generate */ - unsigned int chromosomeSize; + const unsigned int chromosomeSize; /** * Breeding calculations should be done here... @@ -46,9 +47,8 @@ namespace genetic { * @param generationSize Indicates size of the generation * @param chromosomeSize Indicates size of the chromosome */ - Generator(unsigned int generationSize, unsigned int chromosomeSize) { - this->generationSize = generationSize; - this->chromosomeSize = chromosomeSize; + Generator(const unsigned int generationSize, const unsigned int chromosomeSize) + : generationSize(generationSize), chromosomeSize(chromosomeSize) { time_t t; srand((unsigned)time(&t)); diff --git a/include/mutation/mutation.h b/include/mutation/mutation.h index 49b6094..6c2b853 100644 --- a/include/mutation/mutation.h +++ b/include/mutation/mutation.h @@ -1,13 +1,11 @@ #ifndef __MUTATION_MUTATION_H #define __MUTATION_MUTATION_H -#include +#include #include "chromosome.h" #include "generation.h" -using namespace std; - namespace genetic { // namespace mutation { /** @@ -51,7 +49,7 @@ namespace genetic { Generation<_Chromosome> mutate(Generation<_Chromosome>& _generation) { const unsigned int generationSize = _generation.size(); const unsigned int chromosomeSize = _generation[0].size(); - vector<_Chromosome> newGeneration; + std::vector<_Chromosome> newGeneration; for (unsigned int i = 0; i < generationSize; i++) { MutationChanceType random = (rand() % 10000) / 10000.0; diff --git a/include/selection/linearRankSelection.h b/include/selection/linearRankSelection.h index ee119d6..16a3cf8 100644 --- a/include/selection/linearRankSelection.h +++ b/include/selection/linearRankSelection.h @@ -8,8 +8,6 @@ #include "fitness/fitness.h" #include "selection/selection.h" -using namespace std; - namespace genetic { // namespace selection { /** diff --git a/include/selection/rouletteSelection.h b/include/selection/rouletteSelection.h index afb3ac7..bd4e67c 100644 --- a/include/selection/rouletteSelection.h +++ b/include/selection/rouletteSelection.h @@ -8,8 +8,6 @@ #include "chromosome.h" #include "selection.h" -using namespace std; - namespace genetic { // namespace selection { /** diff --git a/include/selection/selection.h b/include/selection/selection.h index 187db12..de899c1 100644 --- a/include/selection/selection.h +++ b/include/selection/selection.h @@ -5,8 +5,6 @@ #include "generation.h" #include "../fitness/fitness.h" -using namespace std; - namespace genetic { // namespace selection { /** diff --git a/src/main.cpp b/src/main.cpp index ccaa43e..a208bbf 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,8 +1,3 @@ -#include -#include -#include -#include - #include "gene.h" #include "chromosome.h" #include "generation.h" @@ -18,7 +13,6 @@ #include "condition/condition.h" #include "condition/generationLimitCondition.h" -using namespace std; using namespace genetic; int main() {