I thought I’d share my binary (half-interval) searcher implementation. The searcher may be used for finding text in a pre-sorted text file.
The advantage of a binary search is that it is extremely fast, especially in large data-sets (thousands or millions of record), when compared to simpler search methods (whether that’s Select-String or Where-Object). However, the search is specialised, if the data is not already sorted it cannot establish a meaningful half interval and therefore cannot find a match.
This implementation jumps about a file stream rather than an array in memory. The reader will always track-back to the beginning of a line before reading the line and attempting a match.