diff data/model/SparseModel.h @ 1114:e80abd659922 3.0-integration

Merge from default branch
author Chris Cannam
date Tue, 07 Jul 2015 17:39:06 +0100
parents ed207f89aaef
children 39019ce29178
line wrap: on
line diff
--- a/data/model/SparseModel.h	Wed Jul 01 18:31:28 2015 +0100
+++ b/data/model/SparseModel.h	Tue Jul 07 17:39:06 2015 +0100
@@ -133,6 +133,12 @@
      */
     virtual void deletePoint(const PointType &point);
 
+    /**
+     * Return true if the given point is found in this model, false
+     * otherwise.
+     */
+    virtual bool containsPoint(const PointType &point);
+    
     virtual bool isReady(int *completion = 0) const {
         bool ready = isOK() && (m_completion == 100);
         if (completion) *completion = m_completion;
@@ -774,6 +780,27 @@
 }
 
 template <typename PointType>
+bool
+SparseModel<PointType>::containsPoint(const PointType &point)
+{
+    {
+	QMutexLocker locker(&m_mutex);
+
+	PointListIterator i = m_points.lower_bound(point);
+	typename PointType::Comparator comparator;
+	while (i != m_points.end()) {
+	    if (i->frame > point.frame) break;
+	    if (!comparator(*i, point) && !comparator(point, *i)) {
+                return true;
+	    }
+	    ++i;
+	}
+    }
+
+    return false;
+}
+
+template <typename PointType>
 void
 SparseModel<PointType>::deletePoint(const PointType &point)
 {