segstore: introduce sorted iterators
[deliverable/tracecompass.git] / statesystem / org.eclipse.tracecompass.segmentstore.core / src / org / eclipse / tracecompass / internal / segmentstore / core / arraylist / ArrayListStore.java
index 6af292cc97c5363b13aa641e0a830b8df332b704..60387b953b3d36513bf4e762274e85ecf25c2f99 100644 (file)
@@ -126,7 +126,12 @@ public class ArrayListStore<@NonNull E extends ISegment> implements ISegmentStor
 
     @Override
     public int size() {
-        return fStore.size();
+        fLock.readLock().lock();
+        try {
+            return fStore.size();
+        } finally {
+            fLock.readLock().unlock();
+        }
     }
 
     @Override
@@ -228,26 +233,6 @@ public class ArrayListStore<@NonNull E extends ISegment> implements ISegmentStor
     // Methods added by ISegmentStore
     // ------------------------------------------------------------------------
 
-    @Override
-    public Iterable<E> getIntersectingElements(long position) {
-        /*
-         * The intervals intersecting 't' are those whose 1) start time is
-         * *lower* than 't' AND 2) end time is *higher* than 't'.
-         */
-        fLock.readLock().lock();
-        try {
-            /*
-             * as fStore is sorted by start then end times, restrict sub array
-             * to elements whose start times <= t as stream.filter won't do it.
-             */
-            int index = Collections.binarySearch(fStore, new BasicSegment(position, Long.MAX_VALUE));
-            index = (index >= 0) ? index : -index - 1;
-            return fStore.subList(0, index).stream().filter(element -> position >= element.getStart() && position <= element.getEnd()).collect(Collectors.toList());
-        } finally {
-            fLock.readLock().unlock();
-        }
-    }
-
     @Override
     public Iterable<E> getIntersectingElements(long start, long end) {
         fLock.readLock().lock();
This page took 0.023986 seconds and 5 git commands to generate.