4 ms·
Comparisons with ImmutableList<T> from Microsoft aren't necessarily valid, since ImmutableList<T> supports insertion and removal at arbitrary points. The implem
by Bognar 12y ago
Comparisons with ImmutableList<T> from Microsoft aren't necessarily valid, since ImmutableList<T> supports insertion and removal at arbitrary points. The implementation in the article is optimized for adding at the end.
- DenisM 12y agoThat's why there are two separate methods on this class - Add (at the end) and Set (anywhere). Both outperform the corresponding ImmutableList<T>, according to the article.
- danbruc 12y agoBut Set can just overwrites the specified element while Insert will insert the element at the specified position by pushing the element and all following elements out of the way.
- SideburnsOfDoom 12y ago> But Set can just overwrites the specified element Kind of: Set returns a new Vector with a changed state (the specified element overwritten). But yes, this implement is very sparse: there's no way to add and remove elements in the middle, no way to even tell how many elements are in the list: https://news.ycombinator.com/item?id=8592178 https://news.ycombinator.com/item?id=8592178 Perhaps omitting them hides some different optimisation choices (i.e. they would be more expensive) Maybe it's just a proof of concept?
- Bognar 12y agoSet is the corollary to SetItem on ImmutableList<T>, not Insert.