find method
Tries to find and return the item index between start
and end
for
which the compareDiff returns TimeComparisonResult.same or
TimeComparisonResult.overlapping, or that is within tolerance
from
target
. If such an item is not fount, the function null.
The arguments must satisfy: 0 <= start
<= end
<= collection.length.
In other words, start
will be considered, but the matching will stop at
element index end
-1.
Implementation
int? find(F target, [num? tolerance, int start = 0, int? end]) {
end = RangeError.checkValidRange(
start,
end,
collection.length,
'start',
'end',
// Don't do expensive string interpolation here, if doing lots of find()
// calls, this may end up taking half the time or more!
'Invalid parameters to find().');
// In order to do tolerance-based evaluations, a function to compute the
// difference must have been provided.
if (tolerance != null) {
ArgumentError.checkNotNull(compareDiff.diffFunc, 'tolerance');
}
return findUnsafe(target, tolerance, start, end);
}