- 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.
推薦閱讀
- Learning LibGDX Game Development(Second Edition)
- Java EE 6 企業級應用開發教程
- 跟老齊學Python:輕松入門
- Building Cross-Platform Desktop Applications with Electron
- TradeStation交易應用實踐:量化方法構建贏家策略(原書第2版)
- LabVIEW虛擬儀器入門與測控應用100例
- Creating Data Stories with Tableau Public
- 響應式Web設計:HTML5和CSS3實戰(第2版)
- 從Excel到Python數據分析:Pandas、xlwings、openpyxl、Matplotlib的交互與應用
- WebStorm Essentials
- Learning Concurrency in Python
- Android應用程序設計
- HikariCP數據庫連接池實戰
- 計算機常用算法與程序設計教程(第2版)
- TypeScript High Performance