*/
package jalview.datamodel.features;
-import jalview.datamodel.SequenceFeature;
-
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import intervalstore.api.IntervalStoreI;
import intervalstore.impl.BinarySearcher;
+import intervalstore.impl.BinarySearcher.Compare;
import intervalstore.impl.IntervalStore;
+import jalview.datamodel.SequenceFeature;
/**
* A data store for a set of sequence features that supports efficient lookup of
* binary search the sorted list to find the insertion point
*/
int insertPosition = BinarySearcher.findFirst(contactFeatureStarts,
- f -> f.getBegin() >= feature.getBegin());
+ true, Compare.GE, feature.getBegin());
contactFeatureStarts.add(insertPosition, feature);
* binary search the sorted list to find the insertion point
*/
insertPosition = BinarySearcher.findFirst(contactFeatureEnds,
- f -> f.getEnd() >= feature.getEnd());
+ false, Compare.GE, feature.getEnd());
contactFeatureEnds.add(insertPosition, feature);
return true;
*/
// int pos = binarySearch(features,
// SearchCriterion.byFeature(feature, RangeComparator.BY_START_POSITION));
- int pos = BinarySearcher.findFirst(features,
- val -> val.getBegin() >= feature.getBegin());
+ int pos = BinarySearcher.findFirst(features, true, Compare.GE,
+ feature.getBegin());
int len = features.size();
while (pos < len)
{
* whose end point is not before the target range
*/
int index = BinarySearcher.findFirst(contactFeatureEnds,
- f -> f.getEnd() >= from);
+ false, Compare.GE, (int) from);
while (index < contactFeatureEnds.size())
{
List<SequenceFeature> result)
{
int index = BinarySearcher.findFirst(contactFeatureStarts,
- f -> f.getBegin() >= from);
+ true, Compare.GE, (int) from);
while (index < contactFeatureStarts.size())
{
*/
package jalview.datamodel.features;
-import jalview.datamodel.SequenceFeature;
-import jalview.io.gff.SequenceOntologyFactory;
-import jalview.io.gff.SequenceOntologyI;
-
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import intervalstore.api.IntervalI;
+import jalview.datamodel.SequenceFeature;
+import jalview.io.gff.SequenceOntologyFactory;
+import jalview.io.gff.SequenceOntologyI;
/**
* A class that stores sequence features in a way that supports efficient
*/
public class SequenceFeatures implements SequenceFeaturesI
{
-
/*
* map from feature type to structured store of features for that type
* null types are permitted (but not a good idea!)
public static void sortFeatures(List<? extends IntervalI> features,
final boolean forwardStrand)
{
- IntervalI.sortIntervals(features, forwardStrand);
+ Collections.sort(features,
+ forwardStrand ? IntervalI.COMPARE_BEGIN_ASC_END_ASC
+ : IntervalI.COMPARE_END_DESC);
}
/**