流是什么意思?它的特点是什么? [英] What does stream means? What are it's characteristics?

查看:214
本文介绍了流是什么意思?它的特点是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

C ++和C#都使用此字符 stream 命名许多类。

C++ and C# both use this word stream to name many classes.


  • C ++: iostream istream ostream stringstream ostream_iterator istream_iterator
  • C#: Stream FileStream MemoryStream BufferedStream 等等。

  • C++ : iostream, istream, ostream, stringstream, ostream_iterator, istream_iterator and so on.
  • C# : Stream, FileStream,MemoryStream, BufferedStream and so on.

要知道 stream 是什么意思?流的特征是什么?我什么时候可以使用这个术语来命名我的课?这只限于文件I / O类?

So it made me curious to know what does stream means? What are the characteristics of a stream? When can I use this term to name my classes? Is this limited to file I/O classes only?

有趣的是,C根据我所知,不会使用这个词。

Interestingly, C doesn’t use this word anywhere, as far as I know.

推荐答案

许多数据结构(列表,集合等)充当容器 - 它们拥有一组对象。但不是流;如果列表是桶,则流是软管。您可以从数据流中提取数据,或将数据推送到数据流(通常只有一次),但只能在一个方向(当然有例外)。例如,网络上的TCP数据是流;您可以发送(或接收)大量数据,但只能与其他计算机连接,通常只能使用一次 - 您不能回退Internet。

Many data-structures (lists, collections, etc) act as containers - they hold a set of objects. But not a stream; if a list is a bucket, then a stream is a hose. You can pull data from a stream, or push data into a stream - but normally only once and only in one direction (there are exceptions of course). For example, TCP data over a network is a stream; you can send (or receive) chunks of data, but only in connection with the other computer, and usually only once - you can't rewind the Internet.

也操纵通过它们的数据;压缩流,加密流等。但是,这里潜在的隐喻是一个数据软管。文件通常也作为流被访问(在某种程度上);您可以访问顺序数据块。当然,大多数文件系统也提供随机访问,所以流提供像Seek,Position,Length等东西 - 但不是所有的实现支持这样。它没有意义寻找一些流,或获得一个开放套接字的长度。

Streams can also manipulate data passing through them; compression streams, encryption streams, etc. But again - the underlying metaphor here is a hose of data. A file is also generally accessed (at some level) as a stream; you can access blocks of sequential data. Of course, most file systems also provide random access, so streams do offer things like Seek, Position, Length etc - but not all implementations support such. It has no meaning to seek some streams, or get the length of an open socket.

这篇关于流是什么意思?它的特点是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆