@Override
public int size() {
- return fStore.size();
+ fLock.readLock().lock();
+ try {
+ return fStore.size();
+ } finally {
+ fLock.readLock().unlock();
+ }
}
@Override
}
}
- @Override
- public boolean remove(@Nullable Object o) {
- throw new UnsupportedOperationException();
- }
-
@Override
public boolean addAll(@Nullable Collection<? extends E> c) {
if (c == null) {
}
}
- @Override
- public boolean removeAll(@Nullable Collection<?> c) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean retainAll(@Nullable Collection<?> c) {
- throw new UnsupportedOperationException();
- }
-
@Override
public void clear() {
fLock.writeLock().lock();
// 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();