/// <summary> /// Uses the <see cref="IScanComparer"/> to scan the byte array for results. /// </summary> /// <param name="data">The data to scan.</param> /// <param name="count">The length of the <paramref name="data"/> parameter.</param> /// <param name="ct">The <see cref="CancellationToken"/> to stop the scan.</param> /// <returns>An enumeration of all <see cref="ScanResult"/>s.</returns> public IList <ScanResult> Search(byte[] data, int count, CancellationToken ct) { Contract.Requires(data != null); var results = new List <ScanResult>(); var endIndex = count - comparer.ValueSize; for (var i = 0; i < endIndex; i += settings.FastScanAlignment) { if (ct.IsCancellationRequested) { break; } if (comparer.Compare(data, i, out var result)) { result.Address = (IntPtr)i; results.Add(result); } } return(results); }
/// <summary> /// Uses the <see cref="IScanComparer"/> to scan the byte array for results. /// </summary> /// <param name="data">The data to scan.</param> /// <param name="count">The length of the <paramref name="data"/> parameter.</param> /// <returns>An enumeration of all <see cref="ScanResult"/>s.</returns> public IEnumerable <ScanResult> Search(byte[] data, int count) { Contract.Requires(data != null); var endIndex = count - comparer.ValueSize; for (var i = 0; i < endIndex; i += settings.FastScanAlignment) { if (comparer.Compare(data, i, out var result)) { result.Address = (IntPtr)i; yield return(result); } } }