]> ruin.nu Git - germs.git/blobdiff - src/genealgorithms.cpp
nicer with size_t for cycles, they can't be negative anyway
[germs.git] / src / genealgorithms.cpp
index a32968eaea3454f1081649335a34c7e8c201077f..7f54109dc6c0103251cafff77bef93d92fa9f1e4 100644 (file)
@@ -66,8 +66,8 @@ struct FindP{
 };
 
 
-int countCycles(const GeneOrder& go){
-       int cycles = 0;
+size_t countCycles(const GeneOrder& go){
+       size_t cycles = 0;
        set<size_t> marked;
        vector<Interval> intervals = findIntervals(go);
        vector<Interval> points = findIntervalsAtPoints(intervals);
@@ -139,10 +139,9 @@ std::vector<Component> findComponents(const GeneOrder& go){
                        os[Sdir.top()] = (os[Sdir.top()] == os[s] ? os[s] : 0);
                        s = Sdir.top();
                }
-               if (go[i] > 0 && dir[i] == dir[s] && i - s == p[i] - p[s])
+               if (go[i] > 0 && dir[i] == dir[s] && static_cast<Gene>(i - s) == p[i] - p[s])
                        components.push_back(Component(p[s],p[i],(s+1 == i ? 0 : os[s])));
 
-
                //Reverse
                if (p[i-1] < p[i])
                        Mrev.push(p[i-1]);
@@ -156,8 +155,8 @@ std::vector<Component> findComponents(const GeneOrder& go){
                        os[Srev.top()] *= (os[Srev.top()] == os[s] ? 1 : 0);
                        s = Srev.top();
                }
-               if (go[i] < 0 && rev[i] == rev[s] && i - s == p[s] - p[i])
-                       components.push_back(Component(-p[s],-p[i],os[s]));
+               if (go[i] < 0 && rev[i] == rev[s] && static_cast<Gene>(i - s) == p[s] - p[i])
+                       components.push_back(Component(-p[s],-p[i],(s+1 == i ? 0 : os[s])));
 
                //Update stacks
                if (go[i] > 0)