in reply to Padding search results with context
You should be able to do it in one iteration...
I would use a queue to store the context lines
Start by inspecting each line.
So, basically, the queue saves up a maximum of $maxPreContext lines of context from before the duplication, and you keep printing $maxPostContext lines for context after the duplication. If another duplicate appears quickly, you don't get multiple copies of the same context because the queue has not refilled.
|
---|