From e20c9d416a4bd5bd9b7259c77e689589625455bf Mon Sep 17 00:00:00 2001 From: James Procter Date: Mon, 21 Aug 2023 15:41:51 +0100 Subject: [PATCH] JAL-4062 revert to ArrayList and integrate check for 'contained' ranges in sweepsearch --- src/jalview/datamodel/SearchResults.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/jalview/datamodel/SearchResults.java b/src/jalview/datamodel/SearchResults.java index 9daa752..d6545ee 100755 --- a/src/jalview/datamodel/SearchResults.java +++ b/src/jalview/datamodel/SearchResults.java @@ -23,8 +23,6 @@ package jalview.datamodel; import java.util.ArrayList; import java.util.BitSet; import java.util.List; -import java.util.SortedSet; -import java.util.TreeSet; /** * Holds a list of search result matches, where each match is a contiguous @@ -37,7 +35,7 @@ public class SearchResults implements SearchResultsI { private int count; - private SortedSet matches = new TreeSet<>(); + private ArrayList matches = new ArrayList<>(); /** * One match consists of a sequence reference, start and end positions. @@ -233,12 +231,7 @@ public class SearchResults implements SearchResultsI { Match m = new Match(sequence, start, end); - Match toAdd=null; - if (matches.contains(m)) - { - return false; - } boolean appending=false; // we dynamically maintain an interval to add as we test each range in the list @@ -249,6 +242,11 @@ public class SearchResults implements SearchResultsI { if (thatm.getSequence()==sequence) { + if (thatm.contains(sequence,cstart,cend)) + { + // found a match containing the current range. nothing else to do except report if we operated on the list + return appending; + } if (thatm.adjacent(sequence, cstart, cend)) { // update the match to add with the adjacent start/end @@ -403,7 +401,7 @@ public class SearchResults implements SearchResultsI @Override public List getResults() { - return List.copyOf(matches); + return matches; } /** -- 1.7.10.2