Scroll::SortWindow
Maintains the top-N lines of the stream by the sort order, for --sort mode.
Rather than accumulate every line, it keeps at most capacity entries, sorted
in display order (least-shown first, most-shown last). Each new line is keyed
once; when the window is full and the new line is not greater than the current
lowest kept entry, it is skipped with a single comparison. Otherwise it
replaces the lowest entry and the window is re-sorted. So memory stays bounded
at N and the common case (a line that does not make the cut) is O(1).
The window's contents are already in display order, so the render path draws
snapshot directly — no further sorting needed.
Constants
Constructors
Instance methods
Feed a chunk of raw bytes; each complete line is offered to the window.
At EOF, optionally offer a trailing newline-less line (the --final option).