Tomes of Delphi by Julian Bucknall describes code for circular buffers, the code of which is freely available for download. I don’t have a book at the moment, so I can’t say exactly where to look (although I think it could have something to do with data compression using a sliding window).
source
share