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

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 BooleanAnyRef 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

主站蜘蛛池模板: 灵川县| 大厂| 资阳市| 建水县| 常熟市| 治县。| 鲜城| 济南市| 太保市| 阿鲁科尔沁旗| 高阳县| 沅陵县| 若尔盖县| 柏乡县| 饶河县| 南昌市| 工布江达县| 鄱阳县| 万载县| 永州市| 麻城市| 丰都县| 青河县| 外汇| 巧家县| 桓仁| 大埔区| 疏勒县| 剑阁县| 浠水县| 巴彦县| 广灵县| 富川| 昌平区| 罗江县| 汪清县| 泸水县| 义马市| 新乐市| 团风县| 循化|