I disagree with that solution. `.reverse` is an O(n) operation, but a
hypothetical `padToFront` might be implemented in O(1) if the collection
supports efficient prepending. If not, it is still faster because only
one copy operation is needed instead of two.
> (or if you think it is, you can pimp it in).
Indeed, that would be the better solution.
Neither of one should be preferred. There are indeed collections which
support efficient appending (or even efficient appending and prepending,
e. g. Finger Trees).
Hi Rex. Lars hit on what I was thinking: if you're only going to include one padTo method, wouldn't it be more efficient to include a prepend one instead, and make people reverse their Lists twice if they want to append (which the implementation would have to do anyway)?
I'm interested why you say there are too many methods. What exactly are these overheads you mention, and what would be the effect on performance if there were, say, 5x as many methods on SeqLike?
Have such things been measured? From a naive (i.e. my) perspective, it looks like the padTo method is only a couple of hundred characters, and presumably even shorter in bytecode. Other missing but potentially useful methods like dropRightWhile would take even less space.
I could try to pimp this method onto the Collections library myself, but as your Stack Overflow Q/A shows, this isn't exactly trivial (beyond the abilities of the average Scala dabbler, at least).