Re: Is there any iterator-like constructs for Streams?

From: Jon Skeet [C# MVP] (skeet_at_pobox.com)
Date: 06/07/04


Date: Mon, 7 Jun 2004 11:42:48 +0100

Peter Rilling <peter@nospam.rilling.net> wrote:
> One nice thing about collections and arrays is that they implement the
> IEnumerator and IEnumerable interfaces which allow for more then one
> iterator to walk the list of items without affecting the position of the
> other iterators. Is there a similar thing with streams? Is there anything
> in the framework that wraps a stream in such a way that the stream position
> is decoupled from the stream itself?

Bear in mind that not every stream is seekable. Once you've read from a
network connection, for instance, you can't go and rewind that. The
stream would have to buffer everything. It's doable, no doubt, but I
don't believe it's provided in the framework.

-- 
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


Relevant Pages

  • Is there any iterator-like constructs for Streams?
    ... IEnumerator and IEnumerable interfaces which allow for more then one ... iterator to walk the list of items without affecting the position of the ... in the framework that wraps a stream in such a way that the stream position ...
    (microsoft.public.dotnet.languages.csharp)
  • I need help debugging an MFC OCX
    ... void CFlintCtrl::DoPropExchange(CPropExchange* pPX) ... This routine is called by the framework and always sets m_bReadAhead to ... Where does this stream come from? ...
    (microsoft.public.win32.programmer.ole)
  • Re: Confused about System.Drawing.Bitmap
    ... Image is an abstract class and Bitmap or Metafile are the two implementations ... to grab the length and width of the file and that is moving your stream. ... You can always reset a stream position back to 0 if you are using seekable ...
    (microsoft.public.dotnet.framework.drawing)
  • portable way to define new stream classes?
    ... In Lispworks I can define my own stream classes, ... I have the source code of the framework and can change it. ... (vector-push-extend byte (slot-value self 'content))) ...
    (comp.lang.lisp)
  • Re: how to dispose of a streamwriter without closing the underlying stream
    ... The reader/writer classes are dependent on encoding and exact byte position, and there's no way to ensure that a reader in particular hasn't read some bytes that are actually part of a different encoding. ... I would guess that since there's not really any reliable way to generalize that kind of functionality, the framework leaves it up to the application to do it, under its full control so that any mistakes in dealing with the mixed data stream are the fault of the application, not the framework. ...
    (microsoft.public.dotnet.languages.csharp)