X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2Ffeatures%2FFeatureStoreImpl.java;h=63ee678938ff819db3c21d2bffb79766f7a7a494;hb=b74cdec4b07000bee431a7cca86a948f44d3ffbe;hp=47c1dd4b79a490d623388a4f866ebde88a1c2b5b;hpb=0031ee4b6a42ad328e417cb65c7a840183e62e87;p=jalview.git diff --git a/src/jalview/datamodel/features/FeatureStoreImpl.java b/src/jalview/datamodel/features/FeatureStoreImpl.java index 47c1dd4..63ee678 100644 --- a/src/jalview/datamodel/features/FeatureStoreImpl.java +++ b/src/jalview/datamodel/features/FeatureStoreImpl.java @@ -25,7 +25,6 @@ import jalview.datamodel.SequenceFeature; import java.util.ArrayList; import java.util.List; -import intervalstore.api.IntervalStoreI; import intervalstore.impl.BinarySearcher; /** @@ -39,18 +38,14 @@ import intervalstore.impl.BinarySearcher; public class FeatureStoreImpl extends FeatureStore { - /** - * Default constructor uses NCList - */ public FeatureStoreImpl() { - this(true); + super(); } - public FeatureStoreImpl(boolean useNCList) + public FeatureStoreImpl(int option) { - features = (useNCList ? new intervalstore.impl.IntervalStore<>() - : new intervalstore.nonc.IntervalStore<>(false)); + super(option); } /** @@ -75,7 +70,7 @@ public class FeatureStoreImpl extends FeatureStore * insert into list sorted by start (first contact position): * binary search the sorted list to find the insertion point */ - int insertPosition = findFirstBeginStatic(contactFeatureStarts, + int insertPosition = findFirstBegin(contactFeatureStarts, feature.getBegin()); contactFeatureStarts.add(insertPosition, feature); @@ -83,7 +78,7 @@ public class FeatureStoreImpl extends FeatureStore * insert into list sorted by end (second contact position): * binary search the sorted list to find the insertion point */ - insertPosition = findFirstEndStatic(contactFeatureEnds, + insertPosition = findFirstEnd(contactFeatureEnds, feature.getEnd()); contactFeatureEnds.add(insertPosition, feature); @@ -95,9 +90,10 @@ public class FeatureStoreImpl extends FeatureStore * (creating the IntervalStore if necessary) */ @Override - protected synchronized void addPositionalFeature(SequenceFeature feature) + protected synchronized boolean addPositionalFeature( + SequenceFeature feature) { - features.add(feature); + return features.add(feature); } /** @@ -142,7 +138,7 @@ public class FeatureStoreImpl extends FeatureStore * find the first contact feature (if any) * whose end point is not before the target range */ - int index = findFirstEndStatic(contactFeatureEnds, from); + int index = findFirstEnd(contactFeatureEnds, from); int n = contactFeatureEnds.size(); while (index < n) @@ -252,46 +248,21 @@ public class FeatureStoreImpl extends FeatureStore private void findOverlaps(long start, long end, List result) { - result.addAll(((IntervalStoreI) features) + result.addAll(features .findOverlaps(start, end)); } @Override protected int findFirstBegin(List list, long pos) { - return findFirstBeginStatic(list, pos); - } - - /** - * Possibly a bit faster using a static method. - * - * @param list - * @param pos - * @return - */ - private static int findFirstBeginStatic(List list, - long pos) - { - return BinarySearcher.findFirst(list, f -> f.getBegin() >= pos); + return BinarySearcher.findFirst(list, (int) pos, + BinarySearcher.fbegin); } @Override protected int findFirstEnd(List list, long pos) { - return findFirstEndStatic(list, pos); - } - - /** - * Possibly a bit faster using a static method. - * - * @param list - * @param pos - * @return - */ - private static int findFirstEndStatic(List list, - long pos) - { - return BinarySearcher.findFirst(list, f -> f.getEnd() >= pos); + return BinarySearcher.findFirst(list, (int) pos, BinarySearcher.fend); } @Override