News for hackers. Stuff that matters.
Re:Appending to an std:string character-by-character: how do... by kadoban on Thursday October 26, 2023 @07:04PM (#38032775)
Depends what you mean by reasonable I suppose. If you just implement it naively, either by growing by 1 or a constant amount each time, it'll be O(n) amortized.

I'd call those potentially reasonable, in that it works and it doesn't break the standard. I probably wouldn't be mad if a student did that impl, but I'd mention it.

I would be surprised if a well-supported, non-toy implementation without strange constraints (eg not for embedded and not trying to optimize solely for size or simplicity or something) did something other than amortized O(1).

There are no comments on this comment yet.