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

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.
主站蜘蛛池模板: 桦甸市| 青阳县| 阿巴嘎旗| 杨浦区| 穆棱市| 泗阳县| 汉中市| 宾川县| 陇西县| 湘潭县| 罗甸县| 桂阳县| 荆门市| 康保县| 团风县| 塔城市| 宜昌市| 抚宁县| 仁寿县| 清河县| 西乡县| 石嘴山市| 上思县| 肥乡县| 江都市| 巴中市| 嘉义县| 新河县| 库伦旗| 昌江| 大理市| 武定县| 榆中县| 出国| 唐河县| 揭东县| 巢湖市| 扎兰屯市| 宽城| 丘北县| 邻水|