3 ms·
"faster than native arrays" as in: native arrays crippled by the requirement of immutability. Appending to a "native array" is amortized constant time. Secondl
by stabbles 7y ago
"faster than native arrays" as in: native arrays crippled by the requirement of immutability.
Appending to a "native array" is amortized constant time. Secondly almost all operations on a "native array" will be faster because there is no overhead in indexing, there is cache locality etc etc. Requiring immutability will almost always reduce performance (yes, I'm aware there a couple operations like concatenation that can potentially run in O(lg n) rather than O(n) when using a tree representation for arrays).
- microcolonel 7y agoIt all comes down to how you're using them. Good tries can perform dramatically better than std::vector-style vectors, given the same development effort, on many kinds of system.
- gjfytfh4256 7y agoThat really strains credulity. What do you mean be dramatically better? Under what read and write access pattern? Do you have specific examples where your claim holds?
- microcolonel 7y agoIf your workload would normally involve regularly copying the vector, no matter what, then it is an easy win. Other factors which can make it worthwhile are access patterns where you have many similar or related vectors which you access at random (especially if you can make some effort to deduplicate those vectors).