What is the complexity for Seq.append? Is it O(1) time and space?

I might add that (a) I should certainly hope so, and (b) I failed to google my way to complexity bounds for Seq module members. If someone know of such, I'd love to have a link to it.

EDIT. I did check the source code before asking. The implementation is here, which will make you look, eventually, at this function, the implementation of which is not immediately accessible to me, and the comments before which puzzles me.

有帮助吗?

解决方案

Yes, it is O(1) because it basically just create a new object that encapsulates the two original sequences.

See source code here

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top