- 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.
- 觸·心:DT時代的大數據精準營銷
- LabVIEW入門與實戰開發100例
- C++ Builder 6.0下OpenGL編程技術
- 信息可視化的藝術:信息可視化在英國
- 新手學Visual C# 2008程序設計
- 差分進化算法及其高維多目標優化應用
- Java項目實戰精編
- 搞定J2EE:Struts+Spring+Hibernate整合詳解與典型案例
- Spring技術內幕:深入解析Spring架構與設計原理(第2版)
- 創意UI:Photoshop玩轉APP設計
- RocketMQ實戰與原理解析
- Web程序設計:ASP.NET(第2版)
- .NET 4.0面向對象編程漫談:應用篇
- Web前端開發技術:HTML、CSS、JavaScript
- Android熱門應用開發詳解