count method
Count occurrences of elements occurring together, with option to include overlap.
1, 2, 1, 2, 1.count(1, 2, 1) returns 1.
1, 2, 1, 2, 1.count(1, 2, 1, overlap: true) returns 2
since the second 1 can be reused.
1, 1, 1.count([]) returns 4 since the indices are 0, 1, 2, 3.
/// Default h.symmetricDeepEquals checks DeepCollectionEquality().equals in both directions since it is asymmetric,
but equalityFunction allows a custom function to be used instead. For asymmetric
equality functions, elements in sub are the second parameter.
Implementation
int count(
Iterable<E> sub, {
bool overlap = false,
bool Function(E a, E b) equalityFunction = h.symmetricDeepEquals,
}) {
return h.countIterable(
original: this,
sublist: sub,
overlap: true,
equalityFunction: equalityFunction,
);
}