Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

Share this Page URL

Chapter 24: The Scala Collections API > 24.13 Performance characteristics - Pg. 549

S ECTION 24.13 · Performance characteristics to a WrappedString , which is a subclass of immutable.IndexedSeq . This conversion was applied in the last line of the previous example in which a string was converted into a Seq . The other, high-priority conversion maps a string to a StringOps object, which adds all methods on immutable se- quences to strings. This conversion was implicitly inserted in the method calls of reverse , map , drop , and slice in the previous example. 24.13 Performance characteristics As the previous explanations have shown, different collection types have different performance characteristics. That's often the primary reason for picking one collection type over another. You can see the performance char- acteristics of some common operations on collections summarized in two tables, Table 24.10 and Table 24.11. The entries in these two tables are explained as follows: C eC aC Log L - The operation takes (fast) constant time. The operation takes effectively constant time, but this might depend on some assumptions such as the maximum length of a vector or the distribution of hash keys. The operation takes amortized constant time. Some invocations of the operation might take longer, but if many operations are performed on average only constant time per operation is taken. The operation takes time proportional to the loga- rithm of the collection size. The operation is linear, that is it takes time propor- tional to the collection size. The operation is not supported. Table 24.10 treats sequence types--both immutable and mutable--with the following operations: 549