In Scala, is there a built-in function or external library for concatenating two lists (or arrays, or vectors, or listbuffers, etc) in constant time? Such an operation would presumably destroy / mutate the two original lists. All the functions I see for concatenating lists run in linear time, as far as I can tell.
Thanks much.
There is the
UnrolledBufferwhich has theconcatmethod taking anotherUnrolledBufferand returning their concatenation inO(1). It is destructive to the argument buffer – the second buffer will be empty after this calling this method.