[phobos] Improvement of stream

Michel Fortin michel.fortin at michelf.com
Mon Jul 5 09:14:24 PDT 2010


Le 2010-07-05 à 1:37, Andrei Alexandrescu a écrit :

> - The Seekable idea is good, I was thinking of it for a while. It expresses a range that is not as cheap for random access as a random-access range, but also that makes random seeking possible. What kind of algorithms could use Seekable?

Well, you might want to skip over certain parts of a stream. Say you know there's 32K bytes of text you don't need, you could just skip it in one go. Or it could allow you to rewind the stream to a previous location (such as when parsing a zip file, where the table of content is at the end of the file and tells you where in the archive each compressed file is located.)

Perhaps you could implement a buffered stream as seekable too, with a seek range limited to the buffer's size. It could act as a form of lookahead, or lookbehind.

But I have to admit the ability of a range to seek outside of the range's range (like rewinding) seems a little odd. It does fit better with a 'stream' concept.

-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/





More information about the phobos mailing list