add method
Add another string to be processed, returns the counts.
Implementation
int? add(String? str) {
_count = _count! + subStringFrequency(str!, _substring!, lastPos: _lastPos)!;
var start = str.length - _substring!.length;
start = start < 0 ? 0 : start;
late var inWord;
int? j;
for (int? i = start; i! < str.length; i++) {
inWord = false;
for (j = 0; j! + i < str.length && j < _substring!.length; j++) {
// If first character in string is a space, skip.
if (i == 0 && str[i].isWhiteSpace) break;
// If the letters dont match in order, break.
if (_substring!.codeUnitAt(j) != str.codeUnitAt(j + i)) {
break;
}
inWord = true;
}
i += j;
}
if (inWord) {
_lastPos = j;
} else {
_lastPos = 0;
}
return _count;
}