官术网_书友最值得收藏!

LinearSeq

Linear sequences have the notion of a head and a tail. The definition looks like trait LinearSeq[+A] extends Seq[A] with LinearSeqOps[A, LinearSeq, LinearSeq[A]] and the class diagram is shown here:

There are three representatives of LinearSeq, all are immutable:

  • List defines three symbolic methods which provide a nice syntax for pattern-matching and building lists. :: prepends element to the list, ::: prepends all elements of a given list, and reverse_::: prepends all elements of a given list but in the reverse order.
  • LazyList is a new immutable collection available since Scala 2.13. It implements a list with a head and a tail, which are not evaluated until needed. As it is superior to Stream, which is only lazy in the tail, Stream is now deprecated. LazyList has two additional methods, force which evaluates it, and lazyAppendAll which lazily appends a given collection to this list.
  • Queue in this hierarchy is also immutable. It allows a first-in-first-out (FIFO) insertion and retrieval of the elements. For this functionality, it defines the enqueue, enqueueAll, dequeue, dequeueOption, and front methods.
主站蜘蛛池模板: 来凤县| 尖扎县| 贵德县| 渭源县| 阿荣旗| 揭西县| 柳河县| 周口市| 洛川县| 奈曼旗| 海宁市| 枞阳县| 化隆| 嘉峪关市| 榆中县| 乌恰县| 岳阳市| 南溪县| 时尚| 安陆市| 玛曲县| 鄂尔多斯市| 安国市| 阜新市| 石狮市| 乡城县| 普兰店市| 铅山县| 南城县| 辽宁省| 岑巩县| 铁岭县| 博罗县| 德江县| 新安县| 云阳县| 乡城县| 东城区| 四平市| 嵊泗县| 健康|