X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FSearchResults.java;h=5c929fc314c1f1a3493d158d2699f8c765949672;hb=c6018dc0dc12720e13b75850a5303279ac7094b7;hp=0074d2a260adb990aeaeeee40ff992845775c4a7;hpb=c1e22e204c48fe7fc30dbb95be46e5a04808898a;p=jalview.git diff --git a/src/jalview/datamodel/SearchResults.java b/src/jalview/datamodel/SearchResults.java index 0074d2a..5c929fc 100755 --- a/src/jalview/datamodel/SearchResults.java +++ b/src/jalview/datamodel/SearchResults.java @@ -33,6 +33,7 @@ import java.util.List; */ public class SearchResults implements SearchResultsI { + private int count; private List matches = new ArrayList<>(); @@ -168,11 +169,30 @@ public class SearchResults implements SearchResultsI if (!matches.contains(m)) { matches.add(m); + count++; } return m; } @Override + public void addResult(SequenceI seq, int[] positions) + { + /* + * we only increment the match count by 1 - or not at all, + * if the matches are all duplicates of existing + */ + int beforeCount = count; + for (int i = 0; i < positions.length - 1; i += 2) + { + addResult(seq, positions[i], positions[i + 1]); + } + if (count > beforeCount) + { + count = beforeCount + 1; + } + } + + @Override public boolean involvesSequence(SequenceI sequence) { final int start = sequence.getStart(); @@ -286,9 +306,9 @@ public class SearchResults implements SearchResultsI } @Override - public int getSize() + public int getCount() { - return matches.size(); + return count; } @Override @@ -329,8 +349,10 @@ public class SearchResults implements SearchResultsI } /** - * Two SearchResults are considered equal if they contain the same matches in - * the same order. + * Two SearchResults are considered equal if they contain the same matches + * (Sequence, start position, end position) in the same order + * + * @see Match#equals(Object) */ @Override public boolean equals(Object obj)