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

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.
主站蜘蛛池模板: 襄城县| 元谋县| 抚州市| 永昌县| 康乐县| 尼木县| 札达县| 辰溪县| 宿松县| 临安市| 武乡县| 五寨县| 金阳县| 湘潭市| 忻州市| 澄江县| 上林县| 肥乡县| 千阳县| 梁山县| 鄂托克前旗| 上高县| 双柏县| 和龙市| 襄樊市| 理塘县| 巴塘县| 睢宁县| 泗阳县| 湾仔区| 慈溪市| 勐海县| 余庆县| 秀山| 临海市| 浮梁县| 东兰县| 五河县| 安陆市| 增城市| 崇仁县|