X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=src%2Freverseaction.h;h=006c9eb4de9df4446b27ccaee6da4068d435a4a2;hb=90e2c43b99205b0d7a300209011231cd8d11f7a0;hp=0330597a90b775c7da1ed89fb118ee59482e1241;hpb=3fff88637ec7e806f19e613051f31ca5178d2cf5;p=germs.git diff --git a/src/reverseaction.h b/src/reverseaction.h index 0330597..006c9eb 100644 --- a/src/reverseaction.h +++ b/src/reverseaction.h @@ -22,6 +22,11 @@ #define __REVERSEACTION_H__ #include "sortaction.h" +#include "genealgorithms.h" + +#include +#include + /** * Reverses an interval * @@ -35,6 +40,10 @@ class ReverseAction : public SortAction{ */ ReverseAction(size_t i, size_t j): SortAction(0),_i(i),_j(j){ } + ReverseAction(Interval i): SortAction(0){ + _i = std::min(i.first,i.second); + _j = std::max(i.first,i.second)-1; + } /** * Applies the sort action on the gene order @@ -51,6 +60,15 @@ class ReverseAction : public SortAction{ } return false; } + + /** + * Gives a string representation of the action, for output + */ + virtual std::string toString() const{ + std::ostringstream os; + os << "[" << _i << "," << _j << "]"; + return os.str(); + } private: size_t _i; size_t _j;