*/
public class SearchResults implements SearchResultsI
{
+ private int count;
private List<SearchResultMatchI> matches = new ArrayList<>();
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();
{
mfound = true;
matchStart = sequence.findIndex(m.start) - 1;
- matchEnd = m.start == m.end ? matchStart : sequence
- .findIndex(m.end) - 1;
+ matchEnd = m.start == m.end ? matchStart
+ : sequence.findIndex(m.end) - 1;
}
if (mfound)
}
@Override
- public int getSize()
+ public int getCount()
{
- return matches.size();
+ return count;
}
@Override
}
/**
- * 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)