Review Request #12639 — Created Sept. 24, 2022 and submitted
BufferedIteratorwraps an existing iterable and allows the consumer to
peek contents without consuming the iterable. It's particularly useful
for parsing output from commands or diff generation, and to allow more
efficient chained processing.
This is implemented as an iterator wrapping another iterator, with a
dequeused to hold the buffer. When peeking, we ensure the buffer has
been populated with the number of items to peek and we return from
there. When consuming or iterating, we start by retrieving items from
the buffer before retrieving from the iterator.
Unit tests pass.
Used this with some in-progress work for chained diff processing.