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

  • Learn Scala Programming
  • Slava Schmidt
  • 185字
  • 2021-06-10 19:35:42

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.
主站蜘蛛池模板: 奉新县| 光山县| 桃江县| 包头市| 岳西县| 武鸣县| 铜山县| 夹江县| 永顺县| 麟游县| 宁阳县| 罗山县| 宜阳县| 新沂市| 新闻| 晴隆县| 韶关市| 蓬莱市| 湾仔区| 运城市| 攀枝花市| 湟中县| 丹阳市| 长阳| 泗洪县| 涪陵区| 沿河| 郑州市| 灵川县| 余姚市| 区。| 榆树市| 枣强县| 上虞市| 兰溪市| 太保市| 滁州市| 黔西县| 田东县| 金门县| 屯留县|