Skip to content

Commit

Permalink
Bugfix: handle DIV/DUP compare in sort
Browse files Browse the repository at this point in the history
  • Loading branch information
mmore500 committed Sep 6, 2023
1 parent cebe8e2 commit d0e4225
Showing 1 changed file with 28 additions and 18 deletions.
46 changes: 28 additions & 18 deletions avida-core/source/main/cPopulation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6711,26 +6711,36 @@ struct sTmpGenotype

inline sTmpGenotype() : id_num(-1), props(NULL) { ; }
inline bool operator<(const sTmpGenotype& rhs) const {
if (source.transmission_type == rhs.source.transmission_type) {
return id_num > rhs.id_num;
} else {
return (
source.transmission_type == Systematics::TransmissionType::DUPLICATION
|| source.transmission_type == Systematics::TransmissionType::DIVISION
|| source.transmission_type == Systematics::TransmissionType::UNKNOWN
);
}
const bool is_parasite = (
source.transmission_type
== Systematics::TransmissionType::HORIZONTAL
|| source.transmission_type
== Systematics::TransmissionType::VERTICAL
);
const bool rhs_is_parasite = (
rhs.source.transmission_type
== Systematics::TransmissionType::HORIZONTAL
|| rhs.source.transmission_type
== Systematics::TransmissionType::VERTICAL
);
if (is_parasite == rhs_is_parasite) return id_num > rhs.id_num;
else return !is_parasite;
}
inline bool operator>(const sTmpGenotype& rhs) const {
if (source.transmission_type == rhs.source.transmission_type) {
return id_num < rhs.id_num;
} else {
return (
source.transmission_type != Systematics::TransmissionType::DUPLICATION
&& source.transmission_type != Systematics::TransmissionType::DIVISION
&& source.transmission_type != Systematics::TransmissionType::UNKNOWN
);
}
const bool is_parasite = (
source.transmission_type
== Systematics::TransmissionType::HORIZONTAL
|| source.transmission_type
== Systematics::TransmissionType::VERTICAL
);
const bool rhs_is_parasite = (
rhs.source.transmission_type
== Systematics::TransmissionType::HORIZONTAL
|| rhs.source.transmission_type
== Systematics::TransmissionType::VERTICAL
);
if (is_parasite == rhs_is_parasite) return id_num < rhs.id_num;
else return is_parasite;
}
inline bool operator<=(const sTmpGenotype& rhs) const {
return !(*this > rhs);
Expand Down

0 comments on commit d0e4225

Please sign in to comment.