Re:Immer: immutable and persistent data structures for C++
by a-nikolaev on Sunday November 27, 2016 @06:03PM
(#13052147)
What do you really mean when you say that the complexity is "effectively" O(1)? Amortized O(1)?
[ Parent
| on HN ]
Re:Immer: immutable and persistent data structures for C++
by arximboldi on Sunday November 27, 2016 @06:31PM
(#13052288)
Thanks for the question, I should add a clarification. It is a term I borrowed from some Scala papers... The idea is that it is actually logarithmic, but the base of the logarithm is very big, so in practice, it is just like a constant (kinda log32 with the default options). With these settings, the biggest vector of ints that fits in 4GB of memory has a depth of 6. And you can store 1M ints in just 4 levels. 1K in 2. This constant is much lower than what you are paying anyways for cache thrashing when working with big vectors. So while from a theorical point of view it is `O(log(n))` considering real programs running on real computers, it is more useful to think of this as a constant factor. Probably I should update the docs with some clarifications or some more honest terminology.
Re:Immer: immutable and persistent data structures for C++
by a-nikolaev on Sunday November 27, 2016 @07:12PM
(#13052485)
Oh, very interesting, thank you!