changeset 204:006fd4cb95b3 memory

Make getRowRange/getColRange operate on first matcher only
author Chris Cannam
date Fri, 27 Feb 2015 12:20:32 +0000
parents 3662865740da
children 010b91e44098
files src/Matcher.cpp
diffstat 1 files changed, 32 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/Matcher.cpp	Fri Feb 27 12:09:43 2015 +0000
+++ b/src/Matcher.cpp	Fri Feb 27 12:20:32 2015 +0000
@@ -140,19 +140,44 @@
 pair<int, int>
 Matcher::getColRange(int i)
 {
-    if (i < 0 || i >= int(m_first.size())) {
-        cerr << "ERROR: Matcher::getColRange(" << i << "): Index out of range"
-             << endl;
-        throw "Index out of range";
+    if (m_firstPM) {
+        if (i < 0 || i >= int(m_first.size())) {
+            cerr << "ERROR: Matcher::getColRange(" << i << "): Index out of range"
+                 << endl;
+            throw "Index out of range";
+        } else {
+            return pair<int, int>(m_first[i], m_last[i]);
+        }
     } else {
-        return pair<int, int>(m_first[i], m_last[i]);
+        return m_otherMatcher->getRowRange(i);
     }
 }
 
 pair<int, int>
-Matcher::getRowRange(int i)
+Matcher::getRowRange(int j)
 {
-    return m_otherMatcher->getColRange(i);
+    if (m_firstPM) {
+
+        //!!! tedious, examine uses (& consider restoring use of
+        //!!! first/last in "other" matcher)
+        int a = -1, b = -1;
+        for (int i = 0; i < int(m_first.size()); ++i) {
+            if (j >= m_first[i] && j < m_last[i]) {
+                if (a == -1) a = i;
+                b = i;
+            }
+        }
+        if (a == -1) {
+            cerr << "ERROR: Matcher::getRowRange(" << j << "): Index out of range"
+                 << endl;
+            throw "Index out of range";
+        } else {
+            return pair<int, int>(a, b + 1);
+        }
+
+    } else {
+        return m_otherMatcher->getColRange(j);
+    }
 }
 
 distance_t