2
什麼是使用SeqView
超過Stream
的用例?Stream v。SeqView
scala> List(1,2).view
res34: scala.collection.SeqView[Int,List[Int]] = SeqView(...)
scala> List(1,2).view.toStream
res33: scala.collection.immutable.Stream[Int] = Stream(1, ?)
或許,如果你需要訪問Stream
的中間,它是昂貴的訪問Stream
元素,那麼你應該使用SeqView
?
這幾乎是這個問題的重複:http://stackoverflow.com/questions/5159000/stream-vs-views-vs-iterators – wheaties
另請參閱:http://stackoverflow.com/questions/4798043/what -is-the-difference-between-the-methods-iterator-and-view和http://stackoverflow.com/questions/3361478/what-are-views-for-collections-and-when-would-you-want -to-use-them – wheaties
謝謝 - 我將刪除此問題 –