Suppose I’m only removing a single element. I would like these methods to implement a fixed size ListBuffer. I would only use if they run in O(1) time. The documentation is slightly ambiguous does anybody know the implementation details?
Suppose I’m only removing a single element. I would like these methods to implement
Share
The relevant implementation is there (for
ListBuffer) and there (forBufferLike).trimStart(n)is linear with respect ton(so, constant if you remove a single element);trimEnd(n)is linear with respect to the size of the collection.Apart from that, I fail to see how you want to have a fixed-size
ListBufferon which you change the size with suchtrimmethods…