changeset 1633:6ac92836cd86 single-point

Further test & fixes
author Chris Cannam
date Tue, 12 Mar 2019 14:56:31 +0000
parents 0890c10e5129
children 687a2453cc15
files base/EventSeries.cpp base/EventSeries.h base/test/TestEventSeries.h
diffstat 3 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/base/EventSeries.cpp	Tue Mar 12 14:52:11 2019 +0000
+++ b/base/EventSeries.cpp	Tue Mar 12 14:56:31 2019 +0000
@@ -293,9 +293,11 @@
     if (pitr == m_events.end() || *pitr != e) {
         return false;
     }
-    ++pitr;
-    if (pitr == m_events.end()) {
-        return false;
+    while (*pitr == e) {
+        ++pitr;
+        if (pitr == m_events.end()) {
+            return false;
+        }
     }
     following = *pitr;
     return true;
--- a/base/EventSeries.h	Tue Mar 12 14:52:11 2019 +0000
+++ b/base/EventSeries.h	Tue Mar 12 14:56:31 2019 +0000
@@ -98,6 +98,8 @@
      * If there are multiple events identical to e in the series,
      * assume that the event passed in is the first one (i.e. never
      * set preceding equal to e).
+     *
+     * It is acceptable for preceding to alias e when this is called.
      */
     bool getEventPreceding(const Event &e, Event &preceding) const;
 
@@ -110,6 +112,8 @@
      * If there are multiple events identical to e in the series,
      * assume that the event passed in is the last one (i.e. never set
      * following equal to e).
+     *
+     * It is acceptable for following to alias e when this is called.
      */
     bool getEventFollowing(const Event &e, Event &following) const;
 
--- a/base/test/TestEventSeries.h	Tue Mar 12 14:52:11 2019 +0000
+++ b/base/test/TestEventSeries.h	Tue Mar 12 14:56:31 2019 +0000
@@ -477,6 +477,7 @@
         s.add(b);
         s.add(c);
         s.add(d);
+        s.add(d); // again
         s.add(a);
         s.add(cc);
         s.add(dd);
@@ -510,6 +511,7 @@
         s.add(b);
         s.add(c);
         s.add(d);
+        s.add(d); // again
         s.add(a);
         s.add(cc);
         s.add(dd);