Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Concatenate lists in constant time in scala?

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.

like image 677
Jeff Avatar asked Jun 11 '11 12:06

Jeff


1 Answers

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.

like image 144
axel22 Avatar answered Sep 20 '22 21:09

axel22