]> ruin.nu Git - germs.git/commitdiff
moved a function and added comment
authorMichael Andreen <harv@ruin.nu>
Wed, 20 Jun 2007 06:57:56 +0000 (06:57 +0000)
committerMichael Andreen <harv@ruin.nu>
Wed, 20 Jun 2007 06:57:56 +0000 (06:57 +0000)
src/genealgorithms.cpp

index 04875daca3031c0803ed527b9a36742d8965289a..24e7b43575ac30a04c46723283a3ee81390a8592 100644 (file)
@@ -65,40 +65,6 @@ struct FindP{
 };
 
 
-std::vector<Interval> findIntervalsAtPoints(const vector<Interval>& intervals){
-       vector<Interval> points;
-       points.push_back(Interval(intervals.size(),intervals.size())); //Dummy interval to match point and index
-       for (size_t p = 1; p <= intervals.size(); ++p){
-               size_t f = 0;
-               size_t s = 0;
-               bool found = false;
-               size_t n = 0;
-               for (vector<Interval>::const_iterator i = intervals.begin(); i != intervals.end(); ++i, ++n){
-                       if (i->first == p){
-                               if (!found){
-                                       f = n;
-                                       found = true;
-                               }else{
-                                       s = n;
-                                       break;
-                               }
-                       }
-                       if (i->second == p){
-                               if (!found){
-                                       f = n;
-                                       found = true;
-                               }else{
-                                       s = n;
-                                       break;
-                               }
-                       }
-               }
-               points.push_back(Interval(f,s));
-       }
-       return points;
-
-}
-
 int countCycles(const GeneOrder& go){
        int cycles = 0;
        set<size_t> marked;
@@ -163,3 +129,40 @@ std::vector<Interval> findIntervals(const GeneOrder& go){
        return intervals;
 }
 
+/**
+ * TODO: Think of a better than O(n^2) implementation.
+ * Possibly move to cache result
+ */
+std::vector<Interval> findIntervalsAtPoints(const vector<Interval>& intervals){
+       vector<Interval> points;
+       points.push_back(Interval(intervals.size(),intervals.size())); //Dummy interval to match point and index
+       for (size_t p = 1; p <= intervals.size(); ++p){
+               size_t f = 0;
+               size_t s = 0;
+               bool found = false;
+               size_t n = 0;
+               for (vector<Interval>::const_iterator i = intervals.begin(); i != intervals.end(); ++i, ++n){
+                       if (i->first == p){
+                               if (!found){
+                                       f = n;
+                                       found = true;
+                               }else{
+                                       s = n;
+                                       break;
+                               }
+                       }
+                       if (i->second == p){
+                               if (!found){
+                                       f = n;
+                                       found = true;
+                               }else{
+                                       s = n;
+                                       break;
+                               }
+                       }
+               }
+               points.push_back(Interval(f,s));
+       }
+       return points;
+
+}