dlugolecki.net.pl
Dziennik
Polecane
Software
projects
/
genetic.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added LinearRankSelection.
[genetic.git]
/
src
/
gene.h
diff --git
a/src/gene.h
b/src/gene.h
index e4142811b3e23bd31724d9a3ae7a243af828e801..781cd3e29d67978dc2b27e965746a1fe53a6f645 100644
(file)
--- a/
src/gene.h
+++ b/
src/gene.h
@@
-4,27
+4,49
@@
namespace genetic {
/**
namespace genetic {
/**
- *
Gene.
+ *
Class representing Gene
*/
template < typename Type >
class Gene {
protected:
*/
template < typename Type >
class Gene {
protected:
+ /**
+ * Value of the Gene
+ * This for example can be a primitive value such as: int or double, or
+ * with additional changes complex struct.
+ */
Type value;
Type value;
+
+ template<typename> friend class Gene;
public:
public:
+ /**
+ * Default constructor
+ */
Gene() {}
Gene() {}
+ /**
+ * Class constructor, initializes Gene with default value.
+ */
Gene(Type value) {
this->value = value;
}
/** Copy constructor */
Gene(Type value) {
this->value = value;
}
/** Copy constructor */
- Gene(const Gene& gene) : value(gene.
get()
) {}
+ Gene(const Gene& gene) : value(gene.
value
) {}
+ /**
+ * Copy operator.
+ *
+ * @param gene Gene from which the value should be copied.
+ * @return Gene instance containing copied value
+ */
Gene& operator=(const Gene& gene) {
Gene& operator=(const Gene& gene) {
- this->value = gene.
get()
;
+ this->value = gene.
value
;
return *this;
}
return *this;
}
+ /**
+ * Allows read-only access to Gene value
+ */
Type get() const {
return value;
}
Type get() const {
return value;
}