Complexity guaranties of array append operator

Dmitriy via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Nov 5 19:48:26 PST 2014


Hello, I'm in the middle of learning D. I can't find any 
definitive information about what is the complexity of operator 
~= when used for adding an element to an array. Is it amortized 
O(1) or is it implementation defined? (I hope it at worst O(n) 
though I haven't seen any information about that either).

Also documentation to std.array.Appender says that "it is more 
efficient" to use Appender "when appending many elements". Does 
it imply that Appender.put has amortized O(1)?


More information about the Digitalmars-d-learn mailing list