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 UnrolledBuffer
which has the concat
method taking another UnrolledBuffer
and returning their concatenation in O(1)
. It is destructive to the argument buffer - the second buffer will be empty after this calling this method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With