- Learn Scala Programming
- Slava Schmidt
- 288字
- 2021-06-10 19:35:42
IndexedSeq
IndexedSeq does not introduce new operations, at least not in its immutable incarnation, but overrides a lots of methods defined in SeqOps to provide more efficient implementations. There are four classes implementing it:
The mutable. IndexedSeq adds the following mutation options: mapInPlace, sortInPlace, sortInPlaceWith, and sortInPlaceBy.
The mutable. ArraySeq is a collection representing an Array. It defines an array method returning an underlying array, and an elemTag method that returns the tag of the element type needed to properly support different kinds of arrays as required by the JVM. Because of this requirement, it has separate implementations for all primitive types including numeric types (in addition to ofByte, there are implementations for all other numeric primitives, not shown on the diagram) and Boolean, AnyRef and Unit.
The immutable. ArraySeq was added in the version 2.13. It is an effectively an immutable sequence that wraps an array and is used to pass varargs parameters. It has the same descendants as its mutable cousin.
Range is an immutable structure that contains integer values. It is defined by start, end, and a step. There are two additional methods available: isInclusive, which is true for Range.Inclusive and false for Range.Exclusive, and by, which creates the new range with a different step but the same start and end.
Vector is an immutable structure that provides constant-time access and updates and fast append and prepend. Because of this, Vector is the default implementation for IndexedSeq, as demonstrated in the following snippet:
scala> IndexedSeq.fill(2)("A")
res6: IndexedSeq[String] = Vector(A, A)
WrappedString is an immutable wrapper over some String. It extends strings with all of the operations defined in IndexedSeqOps.
- Learning Single:page Web Application Development
- JavaScript百煉成仙
- 自己動手實現Lua:虛擬機、編譯器和標準庫
- 基于免疫進化的算法及應用研究
- Python應用輕松入門
- Learning Network Forensics
- Python算法從菜鳥到達人
- 利用Python進行數據分析(原書第3版)
- 零基礎學單片機C語言程序設計
- Working with Odoo
- Python Projects for Kids
- Modernizing Legacy Applications in PHP
- Android編程權威指南(第4版)
- 從零開始學Unity游戲開發(fā):場景+角色+腳本+交互+體驗+效果+發(fā)布
- Java Web應用開發(fā)