17-Jan-2014 18:03, Steven Schveighoffer пишет:
On Fri, 17 Jan 2014 05:01:35 -0500, Dmitry Olshansky
<[email protected]> wrote:
BTW I haven't thought of writing into the buffer, but it works exactly
the same. It could be even read/write -"discarded" data is written to
underlying stream, freshly loaded is read from stream. Now in case of
input stream only writes are nop, for output-only reads are nops.
With pinning it makes for cool multi-pass algorithms that actually
output stuff into the file.
In my experience, the code/process for a write buffer is significantly
different than the code for a read buffer. A read/write buffer is very
difficult to make, because you either need 2 file pointers, or need to
constantly seek the single file pointer to overwrite the existing data.
Agreed, read/write buffer is a bad idea. As for write-only buffer
implemented in the same style as read-only, well I need to try it first.
--
Dmitry Olshansky